C# removing items from listbox

后端 未结 16 2261
礼貌的吻别
礼貌的吻别 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条回答
  •  粉色の甜心
    2020-12-02 00:30

    You can do it in 1 line, by using Linq

    listBox1.Cast().Where(p=>p.Text.Contains("OBJECT")).ToList().ForEach(listBox1.Items.Remove);
    

提交回复
热议问题