0

Por que no me imprime nada en el richTextBox

    String[] Nombre = new string[100];
    String[] ApPaterno = new string[100];
    String[] Folio = new string[100];
    String[] Sexo = new string[100];
    String[] ApMaterno = new string[100];
    int[] año = new int[100];
    int[] mes = new int[100];
    int[] dia = new int[100];

    int i = 0;
    public Form1()
    {

        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if (radio_Guardar.Checked == true)
        {
            Nombre[i] = textBox_nombre.Text;
            ApPaterno[i] = textBox_Paterno.Text;
            ApMaterno[i] = textBox_Materno.Text;
            año[i] = Convert.ToInt32(textBox_año.Text);
            mes[i] = Convert.ToInt32(textBox_Mes.Text);
            dia[i] = Convert.ToInt32(textBox_Dia.Text);

            Folio[i] = (i + 1) + " ";

            label_Folio.Text = Folio[i];

            if (radio_Masculino.Checked == true)
            {
                Sexo[i] = "F";
            }
            if (radio_Femenino.Checked == true)
            {
                Sexo[i] = "M";
            }

            MessageBox.Show("Su nombre es : " + "\n " + Nombre[i] + " " + "\n" + "Apellido Paterno : " + " " + "\n" + ApPaterno[i] + " " + "\n" + "Apellido Materno: " + " " + "\n" + ApMaterno[i] + " " + "\n" + "Sexo:" + Sexo[i] + " " + "\n" + "Folio: " + Folio[i] + " " + "\n" + "año" + " " + año[i] + " " + " \n" + "El mes es :" + mes[i] + " " + "\n" + "Dia: " + dia[i]);


            if (radio_Imprimir.Checked == true )
            {

                for (i = 0; i < 100;i++)
                {

                    richTextBox1.Text += (i + 1) + "nombre" + Nombre[i];
                }
            }


            //Avanzar el apuntador
            i++; 
        }




    }
3
  • si pones un breakpoint en el codigo y avanzas paso a paso, puedes ver que la ejecucion ingresa por los if que valida los checkbox radio_Guardar y radio_Imprimir ? el 23 feb. 2019 a las 2:40
  • El radio_Guardar envia un messagebox de los datos que se ingresaron y el radio_imprir debe imprimir los datos en un richTextBox con el boton aceptar pero no me imprime ningún dato el 23 feb. 2019 a las 3:16
  • El problema es que estas usando la variable i por todos lados y esta definida a nivel de la clase. Entonces el for i la manda a 100.. y ya no sirve mas...
    – gbianchi
    el 23 feb. 2019 a las 5:44

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.