Here is my case: I have a Class Main
which has a field
Button button1 = new Button()
I have retrieved a MemberInfo
from button1
. I would now like to set its IsEnable
property. After many fruitless searches I can't find the solution.
I want to do something like this Object obj = memberInfo.GetInstance();
I've tried this code:
Type type = currentForm.GetType(); // OK
FieldInfo field = type.GetField(member.Name); // OK
Control control = (Control)field.GetValue(member); // Not OK, control is Null
control.IsEnabled = false;
Thank you for your help!
A.
Aucun commentaire:
Enregistrer un commentaire