GetNextControl() method in .NET
O Boy, how something so simple can turn out to be...well...not so simple.
Am I having a blonde day or what the hell is going on here?? I've created a custom control with some Dropdown boxes and Textbox on it. Very basic.
When the user selects an item in the Dropdown...the text in the textbox next to the dropdown must be changed. In order the get to the Textbox I used GetNextControl() method.
My code was as follows: On the Combo's SelectionChanged event
private void comboProducts_SelectionChanged(object sender, EventArgs e)
{
SupplierProductArtifactControl control = (SupplierProductArtifactControl)sender;
Control controlNext =
this.GetNextControl(control , true);
controlNext .Text = “Some Text“;
}
Well, in this case the GetNextControl() method did NOT select the next control.
The controlNext was still the combobox.
But changing the line :
Control controlNext = this.GetNextControl(control , true);
to
Control controlNext = this.GetNextControl(ActiveControl , true);
Made the difference and it worked.
Now what is the difference between “control” in first example and “ActiveControl” in second?