如何修改动态加载的menuitem的onclick事件 0
展开全部
#Region "DataGridView右键菜单"
Public Sub SetContextMenuStrip()
Dim ToolStripMenuItem1 As New System.Windows.Forms.ToolStripMenuItem("查找定位")
Dim ToolStripMenuItem2 As New System.Windows.Forms.ToolStripMenuItem("记录范围筛选")
Dim ToolStripMenuItem3 As New System.Windows.Forms.ToolStripMenuItem("固定列")
Dim ToolStripMenuItem4 As New System.Windows.Forms.ToolStripMenuItem("多列排序")
Dim ContextMenuStrip1 As New ContextMenuStrip
MyGrid.ContextMenuStrip = ContextMenuStrip1
With ContextMenuStrip1.Items
.Add(ToolStripMenuItem1)
.Add(ToolStripMenuItem2)
.Add(ToolStripMenuItem3)
End With
AddHandler ToolStripMenuItem1.Click, AddressOf ToolStripMenuItem_Click
AddHandler ToolStripMenuItem2.Click, AddressOf ToolStripMenuItem_Click
AddHandler ToolStripMenuItem3.Click, AddressOf ToolStripMenuItem_Click
End Sub
Private Sub ToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Select Case sender.text
Case "查找定位"
Me.ShowGridFind()
Case "记录范围筛选"
Me.ShowGridFilter()
Case "固定列"
Me.ShowGridColumn(ColumnProperty.固定列)
End Select
End Sub
#End Region
Public Sub SetContextMenuStrip()
Dim ToolStripMenuItem1 As New System.Windows.Forms.ToolStripMenuItem("查找定位")
Dim ToolStripMenuItem2 As New System.Windows.Forms.ToolStripMenuItem("记录范围筛选")
Dim ToolStripMenuItem3 As New System.Windows.Forms.ToolStripMenuItem("固定列")
Dim ToolStripMenuItem4 As New System.Windows.Forms.ToolStripMenuItem("多列排序")
Dim ContextMenuStrip1 As New ContextMenuStrip
MyGrid.ContextMenuStrip = ContextMenuStrip1
With ContextMenuStrip1.Items
.Add(ToolStripMenuItem1)
.Add(ToolStripMenuItem2)
.Add(ToolStripMenuItem3)
End With
AddHandler ToolStripMenuItem1.Click, AddressOf ToolStripMenuItem_Click
AddHandler ToolStripMenuItem2.Click, AddressOf ToolStripMenuItem_Click
AddHandler ToolStripMenuItem3.Click, AddressOf ToolStripMenuItem_Click
End Sub
Private Sub ToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Select Case sender.text
Case "查找定位"
Me.ShowGridFind()
Case "记录范围筛选"
Me.ShowGridFilter()
Case "固定列"
Me.ShowGridColumn(ColumnProperty.固定列)
End Select
End Sub
#End Region
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询