elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


  Mostrar Mensajes
Páginas: [1]
1  Programación / .NET (C#, VB.NET, ASP) / Ayuda con C# Busqueda dentro de listBox en: 19 Noviembre 2013, 23:21 pm
Buenas a todos.
Tengo un problema, he creado un form en C# donde se registran alumnos. Una ves registrado cada alumno los datos se insertan dentro de unos List Box, todos por separado.

El profesor pide que haga un boton de buscar, donde al ingresar el Código del alumno, muestre todos los datos del mismo.

Este es el programa que hice>

Código:
namespace tarea4_1
{
    public partial class Form3 : Form
    {
        public static string[] codigo = new string[10];
        public static string[] apellido = new string[10];
        public static string[] DNI = new string[10];
        public static string[] carrera = new string[10];
        public static double[] parcial = new double[10];
        public static double[] final = new double[10];
        public static int ca = 0;

       
        public Form3()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string cod, ape, id, car;
            double fin, par;
            cod = textBox1.Text;
            ape = textBox2.Text;
            id = textBox3.Text;
            car = textBox4.Text;
            par = double.Parse(textBox5.Text);
            fin = double.Parse(textBox6.Text);
            codigo[ca] = cod;
            apellido[ca] = ape;
            DNI[ca] = id;
            carrera[ca] = car;
            parcial[ca] = par;
            final[ca] = fin;
            ca++;


        }

        private void button2_Click(object sender, EventArgs e)
        {
            Form4 lista = new Form4();
            lista.Show();
            lista.listBox1.Items.Clear();
            lista.listBox2.Items.Clear();
            lista.listBox3.Items.Clear();
            lista.listBox4.Items.Clear();
            lista.listBox5.Items.Clear();
            lista.listBox6.Items.Clear();
            lista.listBox7.Items.Clear();
            if (ca >= 1)
            {
                for (int i = 0; i <= ca - 1; i++)
                {
                    lista.listBox1.Items.Add(codigo[i]);
                    lista.listBox2.Items.Add(apellido[i]);
                    lista.listBox3.Items.Add(DNI[i]);
                    lista.listBox4.Items.Add(carrera[i]);
                    lista.listBox5.Items.Add(parcial[i]);
                    lista.listBox6.Items.Add(final[i]);
                    lista.listBox7.Items.Add((parcial[i] + final[i]) / 2);
                }
            }
            else
            {
                MessageBox.Show("No hay datos en el registro", "ADVERTENCIA");
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();

        }

        private void button4_Click(object sender, EventArgs e)
        {
            string cod;
            cod = textBox1.Text;
            Form5 buscar = new Form5();
            buscar.Show();
        }
    }
}



Si quieren ver el programa entero les dejo un link a mi dropbox
https://www.dropbox.com/sh/h2t3wdc6lvbbqoq/vckRQ-bIhK
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines