Kind of Eval needed

  • Thread starter Thread starter Nicolas
  • Start date Start date
N

Nicolas

How can I do this in Csharp

private void applyColor(Control ctr, string oProperty, Color newVal)
{
ctr.oProperty= newVal;
}

Need to Evaluate (ctr.oProperty) so the program understand for example
(this.Button1.BackColor = newVal)

Than you for your help
 
Hi,

Of course you can do it using reflection:

ctr.GetType().GetProperty(oProperty).SetValue( ctr,newVal, null);

Hope this help,
 
Thank a billion



Ignacio Machin ( .NET/ C# MVP ) said:
Hi,

Of course you can do it using reflection:

ctr.GetType().GetProperty(oProperty).SetValue( ctr,newVal, null);

Hope this help,
 
Back
Top