Tuesday, 20 August 2013

system.reflection.eventinfo does not contain definition for GetValue

system.reflection.eventinfo does not contain definition for GetValue

I'm aware that to display the Control properties, you just need to use a
code like this
System.Reflection.PropertyInfo[] propertyInfo =
checkBox1.GetType().GetProperties();
for (int i = 0; i < propertyInfo.Length; i++)
{
textBlock.Text = i + " " + propertyInfo[i].Name + "\n" + textBlock.Text;
};
You can also get the names of the Events like this
System.Reflection.EventInfo[] eventInfo = checkBox1.GetType().GetEvents();
for (int i = 0; i < eventInfo.Length; i++)
{
textBlock.Text = eventInfo[i].Name + "\n" + textBlock.Text;
};
But how about to display the Event handlers? I can't just use a GetValue
function like I can for propertyInfo
propertyInfo[i].GetValue(checkBox1, null)
If I try below, I can the error "System.Reflection.EventInfo does not
contain a definition for GetValue"
eventInfo[i].GetValue(checkBox1, null)

No comments:

Post a Comment