Ignacio,
Im Still getting the problem... here is my code:
public Janus.Windows.Ribbon.ButtonCommand CreateButton()
{
m_ButtonControl = new Janus.Windows.Ribbon.ButtonCommand();
m_ButtonControl.Text = m_ButtonText;
if (m_ImageName.Trim().Length 0)
{
m_ButtonControl.LargeImage =
(Image)rm.GetObject(m_ImageName);
}
Assembly assem = Assembly.GetExecutingAssembly();
string currentNamespace =
Assembly.GetExecutingAssembly().GetTypes()[0].Namespace;
Type type = assem.GetType(currentNamespace + "." + m_FormName,
true, true);
MethodInfo methinf = type.GetMethod(MethodCall);
System.Reflection.EventInfo evClick =
m_ButtonControl.GetType().GetEvent("Click");
Type tDelegate = evClick.EventHandlerType;
Delegate d = Delegate.CreateDelegate(tDelegate, type,
MethodCall);
System.Reflection.MethodInfo addHandler =
evClick.GetAddMethod();
Object[] addHandlerArgs = { d };
//addHandler.Invoke(c, addHandlerArgs);
return m_ButtonControl;
}
"Ignacio Machin ( .NET/ C# MVP )" <ig************@gmail.comwrote in
message
news:a0**********************************@l28g2000 prd.googlegroups.com...
On Apr 16, 3:39 pm, "Ron" <rs_herh...@yahoo.comwrote:
I checked out the documentation and its even less clear :-)
The Form that the method is in is called frmTest.
I tried Delegate d = Delegate.CreateDelegate(tDelegate,frmTest,methinf) ;
It's easy , my code use this overload:
Delegate.CreateDelegate (Type, Object, String)
As you see, the first parameter is a Type instance, that I created in
the line above
Type tDelegate = evClick.EventHandlerType;
The second parameter is the instance of the class that will handle the
event ( in your case would be an isntance of the frmTest)
and finally the last parameter is the name of the method (its a member
of frmTest)