Click here to Skip to main content
15,902,189 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralIntraction with a Windows Service Pin
24-Jul-05 23:51
suss24-Jul-05 23:51 
GeneralRe: Intraction with a Windows Service Pin
Corinna John26-Jul-05 2:13
Corinna John26-Jul-05 2:13 
GeneralCeating hyperlink column in datagrid Pin
wEb GuRu...24-Jul-05 19:36
wEb GuRu...24-Jul-05 19:36 
GeneralRe: Ceating hyperlink column in datagrid Pin
Member 210009525-Jul-05 18:45
Member 210009525-Jul-05 18:45 
GeneralAdd event handler for MenuItem click event at right start of event Pin
thanhannt23-Jul-05 15:08
thanhannt23-Jul-05 15:08 
GeneralRe: Add event handler for MenuItem click event at right start of event Pin
[Marc]23-Jul-05 23:01
[Marc]23-Jul-05 23:01 
GeneralRe: Add event handler for MenuItem click event at right start of event Pin
thanhannt24-Jul-05 15:45
thanhannt24-Jul-05 15:45 
GeneralRe: Add event handler for MenuItem click event at right start of event Pin
[Marc]24-Jul-05 17:33
[Marc]24-Jul-05 17:33 
well did some diggin' in the MenuItem class with reflector, and i think here's the thing:
MenuItem has a friend class called MenuItemData. MenuItem also has a private variable of type MenuItemData, called data. MenuItemData has a private EventHandler called onClick, and i think thats the one you're after.
Here's a function i put together (it's in VB.Net though):
Private Shared Function GetMenuItemClickEvent(ByVal item As MenuItem) As EventHandler
    If (item Is Nothing) Then Return Nothing

    Dim allflags As BindingFlags = BindingFlags.Instance Or _
        BindingFlags.Public Or BindingFlags.NonPublic Or _
        BindingFlags.Static Or BindingFlags.FlattenHierarchy

    'Get the MenuItemData from the MenuItem
    Dim data As Object = item.GetType.GetField("data", _
                                          allflags).GetValue(item)
    'Get the onClick EventHandler from data
    Dim clickevent As Object = data.GetType.GetField("onClick", _
                                            allflags).GetValue(data)

    If (clickevent Is Nothing) Then
        'No method is linked to onClick, so onClick is null
        Return Nothing
    Else
        Return DirectCast(clickevent, EventHandler)
    End If
End Function

Cheers! Cool | :cool:









GeneralRe: Add event handler for MenuItem click event at right start of event Pin
thanhannt24-Jul-05 22:47
thanhannt24-Jul-05 22:47 
GeneralRe: Add event handler for MenuItem click event at right start of event Pin
[Marc]25-Jul-05 7:26
[Marc]25-Jul-05 7:26 
GeneralRe: Add event handler for MenuItem click event at right start of event Pin
thanhannt25-Jul-05 16:09
thanhannt25-Jul-05 16:09 
GeneralDataGrid navigate through objects Pin
Jan Vanacek23-Jul-05 1:33
sussJan Vanacek23-Jul-05 1:33 
GeneralLost in Unicode Pin
nemo22-Jul-05 16:02
nemo22-Jul-05 16:02 
GeneralData binding problem with invisible controls Pin
ComputerNerd9270822-Jul-05 6:47
ComputerNerd9270822-Jul-05 6:47 
GeneralRe: Data binding problem with invisible controls Pin
ComputerNerd9270822-Jul-05 9:16
ComputerNerd9270822-Jul-05 9:16 
QuestionHow to resolve path in Linux? Pin
bondguru21-Jul-05 20:33
bondguru21-Jul-05 20:33 
GeneralMouse events in non Control derived class Pin
Mading21-Jul-05 19:37
Mading21-Jul-05 19:37 
Generaldll cannot be registered Pin
bondguru21-Jul-05 19:29
bondguru21-Jul-05 19:29 
GeneralRe: dll cannot be registered Pin
rwestgraham22-Jul-05 14:27
rwestgraham22-Jul-05 14:27 
Generaldlls on .net framework Pin
Weiye Chen21-Jul-05 16:35
Weiye Chen21-Jul-05 16:35 
GeneralRe: dlls on .net framework Pin
Christian Graus21-Jul-05 16:51
protectorChristian Graus21-Jul-05 16:51 
GeneralRe: dlls on .net framework Pin
Weiye Chen21-Jul-05 16:56
Weiye Chen21-Jul-05 16:56 
GeneralRe: dlls on .net framework Pin
Weiye Chen21-Jul-05 17:03
Weiye Chen21-Jul-05 17:03 
GeneralRe: dlls on .net framework Pin
Christian Graus21-Jul-05 17:19
protectorChristian Graus21-Jul-05 17:19 
GeneralRe: iostream and iostream.h Pin
Weiye Chen21-Jul-05 17:37
Weiye Chen21-Jul-05 17:37 

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.