开发者

I want to clear one item in listbox winforms c#

开发者 https://www.devze.com 2023-02-15 12:03 出处:网络
开发者_开发问答I want to clear one item in a listbox winforms c#. How can I get the index of the item?ListBox has a property called SelectedIndex. To remove current selected item you have just to cal
开发者_开发问答

I want to clear one item in a listbox winforms c#.

How can I get the index of the item?


ListBox has a property called SelectedIndex. To remove current selected item you have just to call RemoveAt(int) method.

Example:

int selectedIndex = myListBox.SelectedIndex;
if(selectedIndex >=0)
   myListBox.Items.RemoveAt(selectedIndex);
0

精彩评论

暂无评论...
验证码 换一张
取 消