C1的C1Ribbon有一对非常有用的方法(C1Ribbon).BeginUpdate() 和 (C1Ribbon).EndUpdate()
相当于StopRedraw和ResumeRedraw (也就是停止重绘和开始重绘),可以改善用户体验。
使用方法
Dim a As C1Ribbon.C1Ribbon = BaseMainForm.controls("C1Ribbon1")
a.BeginUpdate()
For Each t As C1Ribbon.RibbonTab In a.Tabs '菜单隐藏
t.Visible = True
Next
a.EndUpdate()
1、Dim a As C1Ribbon.C1Ribbon = BaseMainForm.controls("C1Ribbon1")
获取菜单的原生对象。建议在全局代码中建立一个函数统一获取,防止以后升级时变更,如:
Public Function GetRibbon() As C1Ribbon.C1Ribbon
return BaseMainForm.controls("C1Ribbon1")
End Function
将代码改成
Dim a As C1Ribbon.C1Ribbon = GetRibbon()
2、a.BeginUpdate()
停止重绘
3、对菜单操作
这里可以用狐表自身的方法
如:
For Each t As RibbonMenu.Tab In RibbonTabs '菜单隐藏
t.Visible = bShow
Next |
4、a.EndUpdate()
刷新菜单
[此贴子已经被作者于2017/12/16 8:46:57编辑过]