以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何根据条件显示快捷菜单  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=23974)

--  作者:hanxuntx
--  发布时间:2012/9/26 8:57:00
--  如何根据条件显示快捷菜单

With Tables("凭证")
    If .Current IsNot Nothing
        If .Current.IsNull("经手人") Then
            MessageBox.Show("请先选择经手人","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            For Each itm As RibbonMenu.ContextCommand In e.ContextMenu.Items
                itm.Visible = False
            Next
        Else
            For Each itm As RibbonMenu.RibbonItem In e.ContextMenu.Items
                itm.Visible = True
            Next
        End If
    End If
End With

 

上面的代码是不是繁琐了,还有别的写法吗?


--  作者:jspta
--  发布时间:2012/9/26 9:21:00
--  

Dim bln As Boolean = True
With Tables("凭证")
    If .Current IsNot Nothing
        If .Current.IsNull("经手人") Then
            MessageBox.Show("请先选择经手人","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
            bln = False
        End If
        For Each itm As RibbonMenu.ContextCommand In e.ContextMenu.Items
            itm.Visible = bln
        Next
    End If
End With

 

不太清楚你的用途。如果这个代码执行次数较频繁,那么效率比较低了

[此贴子已经被作者于2012-9-26 9:24:08编辑过]

--  作者:lin_hailun
--  发布时间:2012/9/26 9:48:00
--  
 呃,看代码,好像楼主是想显示,或者不显示弹出菜单。

 表事件不是有一个BeforeShowContextMenu么?

 直接 e.Cancel = true