There is a ComboBox on my Windows Form. I have two different methods that are called when the Form is made visible, depending on what action the user intends to perform. In one case, i want the ComboBox to be tied to an EventHandler, and in the other case, i dont want it to be. So how can i make sure that the EventHandler is not triggered? Here are the two methods in question:
What do i put where the ????? are now (to remove the eventhandler that might have been added previously)? And will the "+=" in the first method give me problems (it might be executed several times).
Code:
public void ShowFormWithEHandler()
{
cbx.SelectedIndexChanged += new EventHandler(TypeValgt);
ShowDialog();
}
public void ShowFormWithoutEHandler()
{
<?????>
ShowDialog();
}
What do i put where the ????? are now (to remove the eventhandler that might have been added previously)? And will the "+=" in the first method give me problems (it might be executed several times).