>>>
>>>UPDATE: I did get this to work. I limited the number of controls I have to search through by putting them in an mmgroupbox and used an arraylist to make it easier to work backwords from the control name to the correct text value.
>>>
>>
>>You don't actually have to run through all of the controls. The Control collection has a Find() method, ex:
>
>Just out of curiosity, isn't that what the Find() method does?
>Tim
I guess it does it behind the scenes, but since it's inner code it should be quicker than doing this explicitly.
>
>
>>
>>
>>string name = "textBox1";
>>Control[] control = this.Controls.Find(name);
>>if (control.Length > 0 && control is TextBox)
>>{
>> TextBox txt = (TextBox)control[0];
>> txt.Text = "My Control";
>>}
>>
>>
>>Or, even simpler:
>>
>>
>>string name = "textBox1";
>>Control control = this.Controls[name];
>>TextBox textBox = control as TextBox;
>>if (textBox != null)
>>{
>> textBox.Text = "My Control";
>>}
>>
If it's not broken, fix it until it is.
My Blog