Foxtable(狐表)用户栏目专家坐堂 → 求助个问题,关于系统菜单目录循环


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

主题:求助个问题,关于系统菜单目录循环

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


加好友 发短信
等级:婴狐 帖子:32 积分:316 威望:0 精华:0 注册:2013/9/14 8:50:00
求助个问题,关于系统菜单目录循环  发帖心情 Post By:2013/9/28 22:43:00 [只看该作者]

For Each a1 As RibbonMenu.Tab In RibbonTabs
    For Each a2 As RibbonMenu.group In a1.Groups
        For Each a3 As  RibbonMenu.RibbonItem  In  a2.Items
            If Typeof a3 Is RibbonMenu.Button

                Output.Show(a3.Text)  这里用a3.name 是没有问题的 但是我想显示出来标题,提示出错,怎么办

            End If
        Next
    Next
Next

以下内容为程序代码:

1 For Each a1 As RibbonMenu.Tab In RibbonTabs
2 For Each a2 As RibbonMenu.group In a1.Groups
3 For Each a3 As RibbonMenu.RibbonItem In a2.Items
4 If Typeof a3 Is RibbonMenu.Button
5
6 Output.Show(a3.Text) 这里用a3.name 是没有问题的 但是我想显示出来标题,提示出错,怎么办
7
8 End If
9 Next
10 Next
11 Next
12
13
14

错误图片


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2013/9/28 22:50:00 [只看该作者]

 代码改成如下


For Each a1 As RibbonMenu.Tab In RibbonTabs
    For Each a2 As RibbonMenu.group In a1.Groups
        For Each a3 As  RibbonMenu.RibbonItem  In  a2.Items
            If Typeof a3 Is RibbonMenu.Button
                Dim o As RibbonMenu.Button = a3
                Output.Show(o.text)  '这里用a3.name 是没有问题的 但是我想显示出来标题,提示出错,怎么办
            End If
        Next
    Next
Next

 回到顶部
帅哥哟,离线,有人找我吗?
kllm868
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:32 积分:316 威望:0 精华:0 注册:2013/9/14 8:50:00
  发帖心情 Post By:2013/9/28 22:52:00 [只看该作者]

说说原理呗 多谢了

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2013/9/28 22:54:00 [只看该作者]

 RibbonItem  没有 text 属性,但是button 有,必须转换一下。

 回到顶部
帅哥哟,离线,有人找我吗?
kllm868
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:32 积分:316 威望:0 精华:0 注册:2013/9/14 8:50:00
  发帖心情 Post By:2013/9/28 23:02:00 [只看该作者]

哦哦 多谢,

 

那么多类型菜单 我怎么区别出来啊


 回到顶部
帅哥哟,离线,有人找我吗?
lsy
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:5246 积分:33163 威望:0 精华:8 注册:2013/1/17 21:28:00
  发帖心情 Post By:2013/9/29 7:26:00 [只看该作者]

下面是做权限表的时候,用到的,楼主可以参考:

 

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


 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2013/9/29 10:33:00 [只看该作者]

以下是引用kllm868在2013-9-28 22:52:00的发言:

说说原理呗 多谢了

 

 

 

原理在这里有讲述:

 

http://www.foxtable.com/help/topics/1926.htm

 


 回到顶部