Click here to Skip to main content
15,899,025 members
Home / Discussions / C#
   

C#

 
GeneralRe: [Announce] diagnosing interop marshaling Pin
Stephane Rodriguez.13-May-03 9:08
Stephane Rodriguez.13-May-03 9:08 
GeneralRe: [Announce] diagnosing interop marshaling Pin
Richard Deeming14-May-03 5:40
mveRichard Deeming14-May-03 5:40 
GeneralRe: [Announce] diagnosing interop marshaling Pin
Stephane Rodriguez.14-May-03 6:55
Stephane Rodriguez.14-May-03 6:55 
GeneralSetting events - beginner question Pin
Neil Lamka13-May-03 4:57
Neil Lamka13-May-03 4:57 
GeneralRe: Setting events - beginner question Pin
Bo Hunter14-May-03 10:02
Bo Hunter14-May-03 10:02 
GeneralRe: Setting events - beginner question Pin
Neil Lamka14-May-03 11:29
Neil Lamka14-May-03 11:29 
GeneralRe: Setting events - beginner question Pin
Bo Hunter16-May-03 19:57
Bo Hunter16-May-03 19:57 
GeneralRe: Setting events - beginner question Pin
Neil Lamka17-May-03 5:30
Neil Lamka17-May-03 5:30 
Ok, Let me try again.

What I'd like to be able to do is (from a class in a managed DLL) to take a method name from a file, create a menu item and set the "OnClick" event to use that method.

What I have been able to figure out is how to set an onclick event handler that resides in my DLL and then to use Invoke to route the event to the desired handler within the application. I was looking for a direct way to wire the event handler to the menu item without the intermediate handling.

I have the MethodInfo for the desired (real) event handler but don't see any way to use that to set the OnClick event using that information.

An example would be something like

<xmlstuff>
<menuitem>
&File
<onclick>My_Handler



....
in the DLL

string caption = ... get the caption from the xml
string onclick = ... get the handler from the xml
MethodInfo mi = ... get the MethodInfo for "My_Handler" (from onclick)
//* I'm using the MagicLibrary .. which is where the MenuCommand lives
MenuCommand mc = new MenuCommand( caption );
mc.Click += ??? using the MethodInfo from above.

What I do have is the above but with

mc.Click += new EventHandler(menu_Click); //menu_Click is my internal handler)


private void menu_Click(object sender, System.EventArgs e)
{
MethodInfo mi = .. get the Method info for the real handler
....
mi.Invoke(_callingInstance, args);
....
}

So..the .Net of what I'm trying to do is to use what I can find out from Reflection to wire a menu item directly to the target event handler without having to use Invoke and this event redirection.

Hope this helps

Neil Lamka
neil@meetingworks.com
GeneralIndex/Custom Control Pin
Kant13-May-03 4:48
Kant13-May-03 4:48 
Questionchanges in a datagrid? Pin
Manster13-May-03 4:26
Manster13-May-03 4:26 
AnswerRe: changes in a datagrid? Pin
Kant13-May-03 4:55
Kant13-May-03 4:55 
GeneralRe: changes in a datagrid? Pin
Manster13-May-03 5:57
Manster13-May-03 5:57 
GeneralRe: changes in a datagrid? Pin
Kant13-May-03 6:36
Kant13-May-03 6:36 
GeneralRe: changes in a datagrid? Pin
Manster13-May-03 7:02
Manster13-May-03 7:02 
GeneralRe: changes in a datagrid? Pin
Kant13-May-03 7:04
Kant13-May-03 7:04 
GeneralRe: changes in a datagrid? Pin
Manster13-May-03 7:39
Manster13-May-03 7:39 
GeneralRe: changes in a datagrid? Pin
Kant13-May-03 8:22
Kant13-May-03 8:22 
GeneralRe: changes in a datagrid? Pin
Manster13-May-03 8:59
Manster13-May-03 8:59 
GeneralRe: changes in a datagrid? Pin
Manster13-May-03 13:03
Manster13-May-03 13:03 
GeneralMenus Pin
Omega50113-May-03 0:57
Omega50113-May-03 0:57 
GeneralRe: Menus Pin
cdehelean13-May-03 1:56
cdehelean13-May-03 1:56 
GeneralRe: Menus Pin
Omega50113-May-03 4:57
Omega50113-May-03 4:57 
Questionan error of M$ VS .NET IDE fatware?!? Pin
cruscal13-May-03 0:23
cruscal13-May-03 0:23 
GeneralSerious bug in Array class Pin
leppie12-May-03 23:09
leppie12-May-03 23:09 
GeneralRe: Serious bug in Array class Pin
leppie13-May-03 0:46
leppie13-May-03 0:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.