Help! This would be awesome! (i.e. Reflection?)
Here's a simple example (maybe not the best) of what I want to do.
I have a textbox defined on my form:
TextBox textBox1 = new TextBox();
A string contains the name of my textbox:
string strControlName = "textBox1";
A string contains the text I want my textbox to display:
string strControlText = "Hello World";
How can I set the text property of my TextBox using the string I defined without looping through the controls on my form and checking if the controlname = strControlName.
In a previous language I knew you could use 'Indirection'. This acted similar to this:
Set (@strControlName).Text = strControlText.
The end result was textBox1.Text = "Hello World".
I was told Reflection acts similarly. Please provide a code example similar to my situation above.
Here's a simple example (maybe not the best) of what I want to do.
I have a textbox defined on my form:
TextBox textBox1 = new TextBox();
A string contains the name of my textbox:
string strControlName = "textBox1";
A string contains the text I want my textbox to display:
string strControlText = "Hello World";
How can I set the text property of my TextBox using the string I defined without looping through the controls on my form and checking if the controlname = strControlName.
In a previous language I knew you could use 'Indirection'. This acted similar to this:
Set (@strControlName).Text = strControlText.
The end result was textBox1.Text = "Hello World".
I was told Reflection acts similarly. Please provide a code example similar to my situation above.
Last edited: