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!
精彩评论