Using a string to access a label?
Hi all and thanks for taking a look at my problem. I apologize if my question isn't exactly clear.
I am using .NET 1.1 VS 2003.
I would like to be able to set the text of a label using two separate strings. The best way I can describe what I would like to do is something like
"label1".text = otherString;
Where "label1" and otherString are both string objects.
"label1" (n-1) is a string that occurs in an array of strings immediately before otherString (n). So I am wanting to loop through this array, check each odd array element, use that string to access a label and set the text of that label with the next even array element.
I have found some things like System.Reflection. Is this the correct way to go about doing what I am trying to do? Is there a better way of doing this? Can it even be done?
Thanks!
Re: Using a string to access a label?
First of all you need to know what the parent control is, then use "ParentControl.Controls.Find()" to get the control. If the label control is just a child of form, use "this.Controls.Find()".
Hope it helps.