dimanche 12 février 2017

How to make a listbox item not duplicate itself to the next line of the listbox in C#

Vote count: 0

so I am adding an item in a listbox by clicking an image. If the item gets clicked or added multiple times,it duplicates itself to the next line of the listbox. What I want is the item to have a counter that will count the number of instance it was clicked.

here's my code so far:

int ctr = 1;
 private void item_img1_Click(object sender, EventArgs e)
        {

            if (!orderList.Items.Contains(item1.Text))
            {
                orderList.Items.Add(item1.Text + ctr);
                ctr++;
            }

        } 

asked 1 min ago

Let's block ads! (Why?)



How to make a listbox item not duplicate itself to the next line of the listbox in C#

Aucun commentaire:

Enregistrer un commentaire