下面是做权限表的时候,用到的,楼主可以参考:
DataTables("权限表").DataRows.Clear()
'''--------------功能区菜单
For Each rtb As RibbonMenu.Tab In RibbonTabs
For Each grp As RibbonMenu.Group In rtb.Groups
For Each itm As RibbonMenu.RibbonItem In grp.Items
Dim dr As DataRow = DataTables("权限表").AddNew()
dr("表窗口功能区") = rtb.Name
dr("列控件功能组") = grp.Name
dr("菜单按钮") = itm.Name
If Typeof itm Is RibbonMenu.ToolBar OrElse Typeof itm Is RibbonMenu.ComboBox _
OrElse Typeof itm Is RibbonMenu.FontComboBox OrElse Typeof itm Is RibbonMenu.MenuButton _
OrElse Typeof itm Is RibbonMenu.SplitButton OrElse Typeof itm Is RibbonMenu.ToggleGroup Then
For Each itm1 As RibbonMenu.RibbonItem In RibbonTabs(rtb.Name)(grp.Name)(itm.Name).Items
Dim dr1 As DataRow = DataTables("权限表").AddNew()
dr1("表窗口功能区") = rtb.Name
dr1("列控件功能组") = grp.Name
dr1("菜单按钮") = itm.Name
dr1("标准按钮") = itm1.Name
If Typeof itm1 Is RibbonMenu.ToolBar OrElse Typeof itm1 Is RibbonMenu.ComboBox _
OrElse Typeof itm1 Is RibbonMenu.FontComboBox OrElse Typeof itm1 Is RibbonMenu.MenuButton _
OrElse Typeof itm1 Is RibbonMenu.SplitButton OrElse Typeof itm1 Is RibbonMenu.ToggleGroup Then
For Each itm2 As RibbonMenu.RibbonItem In RibbonTabs(rtb.Name)(grp.Name)(itm.Name)(itm1.Name).Items
Dim dr2 As DataRow = DataTables("权限表").AddNew()
dr2("表窗口功能区") = rtb.Name
dr2("列控件功能组") = grp.Name
dr2("菜单按钮") = itm.Name
dr2("标准按钮") = itm1.Name
dr2("末级按钮") = itm2.Name
Next
End If
Next
End If
Next
Next
Next
'''----------------程序菜单左
For Each itm As RibbonMenu.RibbonItem In ApplicationMenu.LeftItems
Dim dr As DataRow = DataTables("权限表").AddNew()
dr("表窗口功能区") = "ApplicationMenu"
dr("列控件功能组") = "LeftItems"
dr("菜单按钮") = itm.Name
Next
'''----------------程序菜单右
For Each itm As RibbonMenu.RibbonItem In ApplicationMenu.RightItems
Dim dr As DataRow = DataTables("权限表").AddNew()
dr("表窗口功能区") = "ApplicationMenu"
dr("列控件功能组") = "RightItems"
dr("菜单按钮") = itm.Name
Next
'''----------------程序菜单底
For Each itm As RibbonMenu.RibbonItem In ApplicationMenu.BottomItems
Dim dr As DataRow = DataTables("权限表").AddNew()
dr("表窗口功能区") = "ApplicationMenu"
dr("列控件功能组") = "BottomItems"
dr("菜单按钮") = itm.Name
Next
'''----------------快速访问栏
For Each itm As RibbonMenu.RibbonItem In QAT.Items
Dim dr As DataRow = DataTables("权限表").AddNew()
dr("表窗口功能区") = "快速访问栏"
dr("列控件功能组") = "快速访问栏"
dr("菜单按钮") = itm.Name
Next
'''----------------配置栏
For Each itm As RibbonMenu.RibbonItem In ConfigBar.Items
Dim dr As DataRow = DataTables("权限表").AddNew()
dr("表窗口功能区") = "配置栏"
dr("列控件功能组") = "配置栏"
dr("菜单按钮") = itm.Name
Next
'''----------------快捷菜单
For Each conmenu As RibbonMenu.ContextMenu In ContextMenus
For Each cmd As RibbonMenu.ContextCommand In conmenu.Items
Dim dr As DataRow = DataTables("权限表").AddNew()
dr("表窗口功能区") = "快捷菜单"
dr("列控件功能组") = conmenu.Name
dr("菜单按钮") = cmd.Name
Next
Next