I hope you can help me with the following question:
I have the next table where i store the menuitem info.
In the onAcion field I stored the info about the event that must be called when the menuitem clicked. (In ms Access i used the Commandbar..OnAction = rst("MeOnAction") methode)
So far so good and i used the data in the next sub
My question is if it is posible to add dynamic the OnAction string as a eventhandler. Your awnser is welcome
I have the next table where i store the menuitem info.
In the onAcion field I stored the info about the event that must be called when the menuitem clicked. (In ms Access i used the Commandbar..OnAction = rst("MeOnAction") methode)
VB.NET:
SELECT [MeShortcutMenuBarDetailsID]
,[MeShortcutMenuBarId]
,[MeCaption]
,[MeOnAction]
,[MeBeginGroup]
,[MeFaceId]
FROM [DesignMaster].[dbo].[MeShortcutMenuBarDetails]
So far so good and i used the data in the next sub
VB.NET:
Public Sub Create_ContextMenu(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
Dim contextMenuStrip As ContextMenuStrip
Dim firstItem As ToolStripMenuItem
'Dim subItem As ToolStripMenuItem
Dim oconn As New SBConnector.ADODBTools
Dim oHandler As New _EventBuilder
contextMenuStrip = New ContextMenuStrip()
Dim rdr As SqlDataReader = oconn.GetReader("SELECT S.MeShortcutMenuBarName, I.MeCaption, I.MeOnAction, I.MeBeginGroup, I.MeFaceId" & _
" FROM dbo.MeShortcutMenuBar AS S INNER JOIN" & _
" dbo.MeShortcutMenuBarDetails AS I ON S.MeShortcutMenuBarID = I.MeShortcutMenuBarId" & _
" WHERE S.MeShortcutMenuBarName = N'" & ContextName & "'")
While rdr.Read()
If IsDBNull(CType(rdr.Item("MeCaption"), String)) Then
Exit While
End If
firstItem = New ToolStripMenuItem(CType(rdr.Item("MeCaption"), String), Nothing, New System.EventHandler(AddressOf Me.Handle_ContextMenuClick))
If Not IsDBNull(rdr.Item("MeOnAction")) Then firstItem.Tag = CType(rdr.Item("MeOnAction"), String)
contextMenuStrip.Items.Add(firstItem)
End While
contextMenuStrip.Show(sender, e.X, e.Y)
End Sub
My question is if it is posible to add dynamic the OnAction string as a eventhandler. Your awnser is welcome