Sunday, December 28, 2014

How to represent class use variable

If you want to change the value of Property.Text at runtime you can try to use below



PropertyInfo[] properties;
int i = 0;

foreach (Control ctrl in this.Controls)
{
if (ctrl is Button)
{
i++;
properties = ctrl.GetType().GetProperties();

foreach (PropertyInfo property in properties)
{
if (property.Name == "Text")
property.SetValue(ctrl,"button" + i,null);
}
}
}

----------------------------------------------


Hope above help !


Doanh


No comments:

Post a Comment