I have 2 errors in my code and cannot figure out how to solve this.
This is my code:
private void add_button_Click(object sender, EventArgs e)` { try { if (list_selected.Contains(List_selection.SelectedItem)) { MessageBox.Show("Can't add the same type twice"); } else { list_selected.Items.Add(List_selection.SelectedItem); } } catch { { MessageBox.Show("No type selected"); } } }
These are the errors:
Error 1
The best overloaded method match for 'System.Windows.Forms.Control.Contains (System.Windows.Forms.Control)' has some invalid arguments
Error 2
Argument 1: cannot be converted from 'object' to 'System.Windows.Forms.Control' C: \ Projects \ flashloader2013 \ mainapplication \ Form1.cs 467 44
Please help me. ]
List_selection and list_selected are ListBoxes .
source share