How to delete object from combobox?

前端 未结 6 1953
遇见更好的自我
遇见更好的自我 2021-01-25 18:37

I have a combobox with objects of Foo type, here is the Foo class:

public class Foo
{
    public string name { get; set; }
    public s         


        
6条回答
  •  南方客
    南方客 (楼主)
    2021-01-25 18:44

    Use ComboBox.SelectedIndex property.

    For example: let me have comboBox1 added to the form. In the delete button:

    if (comboBox1.SelectedIndex >= 0)
        comboBox1.Items.RemoveAt(comboBox1.SelectedIndex);
    

提交回复
热议问题