右键菜单的自定义可以考虑参考:http://www.sanmugrid.com/help/in ... ShowContextMenu.htm
http://www.sanmugrid.com/help/in ... %8F%9C%E5%8D%95.htm
具体到本贴中的需要删除一个菜单,可以参考下面的代码。如果想在多表实现相同效果,记得将代码放到全局表事件中去。
- public void BeforeShowContextMenu(object sender, sanMuSoft.CS.WinForm.BeforeShowContextMenuEventArgs e)
- {
- switch (e.HitType)
- {
- case HitTestTypeEnum.None: //空白区域
- {
- // 遍历所有菜单
- foreach (SmCommandLink item in e.ContextMenu.CommandLinks)
- {
- if(item.Text=="新增多行")
- {
- //这个可能会影响其他地方的新增多行的命令,可以试试
- item.Command.Visible=false;
- }
- }
- break;
- }
-
- default:
- {
- break;
- }
- }
-
- }
复制代码
Vb.net版本的代码
- Public Sub BeforeShowContextMenu(sender As Object, e As BeforeShowContextMenuEventArgs)
- Select Case e.HitType
- Case HitTestTypeEnum.None '空白区域
- ' 遍历所有菜单
- For Each item As SmCommandLink In e.ContextMenu.CommandLinks
- If item.Text = "新增多行" Then
- '这个可能会影响其他地方的新增多行的命令,可以试试
- item.Command.Visible = False
- End If
- Next
- Case Else
- ' Do nothing
- End Select
- End Sub
复制代码
|