Foxtable(狐表)用户栏目专家坐堂 → 如何根据条件显示快捷菜单


  共有9490人关注过本帖树形打印复制链接

主题:如何根据条件显示快捷菜单

帅哥哟,离线,有人找我吗?
hanxuntx
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:九尾狐 帖子:2609 积分:16926 威望:0 精华:11 注册:2011/9/20 16:13:00
如何根据条件显示快捷菜单  发帖心情 Post By: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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:七尾狐 帖子:1732 积分:11272 威望:0 精华:0 注册:2011/12/15 22:06:00
  发帖心情 Post By: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
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:6708 积分:34304 威望:0 精华:11 注册:2012/8/18 23:10:00
  发帖心情 Post By:2012/9/26 9:48:00 [只看该作者]

 呃,看代码,好像楼主是想显示,或者不显示弹出菜单。

 表事件不是有一个BeforeShowContextMenu么?

 直接 e.Cancel = true

 回到顶部