Properties List

Properties List

Post by Ori » Thu, 29 May 2003 10:51:53



1 How do I query a control to get a list of all properties?
2 How do I set a propery at runtime by its name?

For item 2:
 I know about MyControl.MyProperty = "1234"
 I want something like MyControl.properties("MyProperty") = "1234"

Thank you

 
 
 

Properties List

Post by Dan » Thu, 29 May 2003 11:18:04


Let's assume the control is a textbox. and we want to
assign the Text property using a method I think your
looking for. Add the System.Reflection namspace to the
class/form your working with.

using System.Reflection;

TextBox txtBox = new TextBox();
PropertyInfo prop = txtBox.GetType().GetProperty("Text");
prop.GetSetMethod().Invoke(this.textBox1,new object[1]
{"test"});

Quote:>-----Original Message-----
>1 How do I query a control to get a list of all
properties?
>2 How do I set a propery at runtime by its name?

>For item 2:
> I know about MyControl.MyProperty = "1234"
> I want something like MyControl.properties

("MyProperty") = "1234"
Quote:

>Thank you

>.