C# removing items from listbox

后端 未结 16 2247
礼貌的吻别
礼貌的吻别 2020-12-02 00:12

I have a listbox being populated from a SQLDATA pull, and it pulls down some columns that i dont want like OBJECT_dfj, OBJECT_daskd. The key is all of these being with OBJE

16条回答
  •  -上瘾入骨i
    2020-12-02 00:32

    With this code you can remove every item from your listbox ... Notice that you should write this code in the click event of your button :

            if (listBox1.SelectedIndex != -1)
            {
                listBox1.Items.RemoveAt(listBox1.SelectedIndex);
            } 
    

提交回复
热议问题