Jump to content

eliminar 1 elementos a nossa escolha de uma listbox


Ricardo_34100
 Share

Recommended Posts

eu tnh assim mas dame excepçao:

private void button1_Click(object sender, EventArgs e)

        {

            if (listBoxNome.SelectedIndex >= 0)

            {

                DialogResult decisao;

                decisao = MessageBox.Show("quer mesmo apagar?" + Environment.NewLine + label4.Text, "Apagar?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if(decisao==DialogResult.Yes)

                {

                    listBoxNome.Items.RemoveAt(listBoxNome.SelectedIndex);

                    listBoxNumero.Items.RemoveAt(listBoxNumero.SelectedIndex);

                }

            }

        }

Link to comment
Share on other sites

private void buttonAdicionar_Click(object sender, EventArgs e)

        {

            FormAdicionar fAdd = new FormAdicionar();

            fAdd.ShowDialog();

            if (fAdd.DialogResult == DialogResult.OK)

            {

                infoAlunos.adicionar(fAdd.Aluno);

                listBoxNumero.Items.Add(fAdd.Aluno.Numero);

                listBoxNome.Items.Add(fAdd.Aluno.Nome);

                Graphics gdi = pictureBoxGrafico.CreateGraphics();

                int j = 0;

                foreach (Aluno al in infoAlunos.Al)

                {

                    for (int i = 0; i < al.Numero.ToString().Length; i++)

                    {

                        gdi.FillEllipse(Brushes.Green, 14 * i, 14 * j, 14, 14);

                       

                    }

                    j++;

                }

            }

        }

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.