How can i check whether ComboBox.SelectIndexchanged Event does not holding any method.
Here i am having methods to Add and Rovemo methods to and from ComboBox which can serve for any comboBox.
public static void AddMethodToComoBox(EventHandler MetodName, ComboBox cbm)
{
if(cbm.SelectedIndexChanged==null)
{
cm.SelectedIndexChanged += MetodName;
}
}
public static void RemoveMethodToComoBox(EventHandler MetodName, ComboBox cbm)
{
if (cbm.SelectedIndexChanged != null)
{
cbm.SelectedIndexChanged -= MetodName;
}
}
If i want to add a method means simply i will call this add method and pass CmoboBox object and Method need to Add similarly to Romove.
But the problem here is if i click a comboBox twice then the method will call twice. so to avoid that i am checking whether the ComboBox's selectedIndexChanged event is already holding any Mthod. If it is then code will not add the same method again. For that i used the If Condition. but it showing error. How can i achieve this???