开发者

How to remove a combobox item from a listview?

开发者_开发知识库

I am trying to make it so: once I click on the remove button, it removes combobox's text from the listview.

private void button2_Click_1(object sender, EventArgs e)
        {
            string sel = combobox.SelectedItem.ToString();
            repository.RemoveNumber(sel);
            view.Items.Remove(sel);
        }


I think that you can do something like

private void button1_Click(object sender, EventArgs e)
    {
        if (comboBox1.SelectedItem != null)
        {
            foreach (ListViewItem item in listView1.Items)
                if (item.Text == comboBox1.SelectedItem.ToString()) listView1.Items.Remove(item);
        }
    }

Hope this helps!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜