怎样动态触发ToolStripMenuItem菜单的点击事件

 我来答
百度网友96ffcf7
2015-01-26 · 知道合伙人互联网行家
百度网友96ffcf7
知道合伙人互联网行家
采纳数:22721 获赞数:118724
从事多年网络方面工作,有丰富的互联网经验。

向TA提问 私信TA
展开全部
#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
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式