I followed discussion "access form control propertys via control name as string " but am getting NullReferenceEx ception when trying to access any controls via their name using "this.Contr ols[CONTROL_NAME]".
private void mtbPh0_Leave(ob ject sender, EventArgs e)
{
string callingControl = (sender as MaskedTextBox). Name;
this.Controls[callingControl].Visible=false;
I've manipulated callingControl to increment the last character, and I've tried just replacing the control name in the last line with a string (control name for a control that exists), but no matter what I do i get the NullReferenceEx ception.
Is my syntax incorrect?
private void mtbPh0_Leave(ob ject sender, EventArgs e)
{
string callingControl = (sender as MaskedTextBox). Name;
this.Controls[callingControl].Visible=false;
I've manipulated callingControl to increment the last character, and I've tried just replacing the control name in the last line with a string (control name for a control that exists), but no matter what I do i get the NullReferenceEx ception.
Is my syntax incorrect?
Comment