Jump to content
nando4

Eliminar item de uma ListView

Recommended Posts

nando4

Boas...

Alguem sabe como se elimina um determinado item de uma listView?

O código que estou a usar para preencher a listView a partir de uma tabela da BD:

//define um item listview
            ListViewItem item;

            SqlCommand cmd3 = new SqlCommand("SELECT * FROM provisoria WHERE id_venda = '" + listView1.FocusedItem.Text + "'", liga);
            SqlDataReader dr1 = cmd3.ExecuteReader();
            while (dr1.Read())
            {
                item = new ListViewItem();
                item.Text = dr1.GetValue(0).ToString();
                //preenche o listview com itens
                for (int i = 1; i < dr1.FieldCount; i++)
                {
                    item.SubItems.Add(dr1.GetValue(i).ToString());
                    
                }

Abraço

Share this post


Link to post
Share on other sites
nando4

Boas

Já consegui resolver, guardei os dados da listview numa tabela provisoria da BD, eliminei o item que queria na BD, eliminei todos os dados da listview, e voltei a preencher a listview com os items que queria.

Abraço

Share this post


Link to post
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

×
×
  • 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.