Foxtable(狐表)用户栏目专家坐堂 → 如何获取快捷菜单的子菜单


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

主题:如何获取快捷菜单的子菜单

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


加好友 发短信
等级:二尾狐 帖子:521 积分:4784 威望:0 精华:0 注册:2014/1/16 16:55:00
如何获取快捷菜单的子菜单  发帖心情 Post By:2014/8/19 17:24:00 [只看该作者]

' 如何判断快捷菜单的子菜单(写了六层,有需要,可以继续添加,用最笨的办法写的)

 

Dim El_MU As RibbonMenu.ContextMenu
Dim EL_MN As String = "测试子菜单"  '
For Each El_MU In ContextMenus
EL_MN = EL_MU.NAME
For Each M1 As object In ContextMenus(EL_MN).Items
    Dim P1 As System.Reflection.PropertyInfo = ContextMenus(EL_MN).Items(M1.name).Gettype().GetProperty("Items")
    If P1 IsNot Nothing Then
        output.show(M1.text & "-" & M1.name  & "  " & "有子菜单")
        For Each M2 As object In  ContextMenus(EL_MN).Items(M1.name).Items
            Dim P2 As System.Reflection.PropertyInfo = ContextMenus(EL_MN).Items(M1.name).Items(M2.name).Gettype().GetProperty("Items")
            If P2 IsNot Nothing Then
                output.show(M2.text & "-" & M2.name & "  " & "有二级子菜单")
                For Each M3 As object In ContextMenus(EL_MN).Items(M1.name).Items(M2.Name).Items
                    Dim P3 As System.Reflection.PropertyInfo = ContextMenus(EL_MN).Items(M1.name).Items(M2.name).Items(M3.Name).Gettype().GetProperty("Items")
                    If P3 IsNot Nothing Then
                        output.show(M3.text & "-" & M3.name & "  " & "有三级子菜单")
                        For Each M4 As object In ContextMenus(EL_MN).Items(M1.name).Items(M2.Name).Items(M3.Name).Items
                            Dim P4 As System.Reflection.PropertyInfo = ContextMenus(EL_MN).Items(M1.name).Items(M2.name).Items(M3.Name).Items(M4.Name).Gettype().GetProperty("Items")
                            If P4 IsNot Nothing Then
                                output.show(M4.text & "-" & M4.name & "  " & "有四级子菜单")
                                For Each M5 As object In ContextMenus(EL_MN).Items(M1.name).Items(M2.Name).Items(M3.Name).Items(M4.Name).Items
                                    Dim P5 As System.Reflection.PropertyInfo = ContextMenus(EL_MN).Items(M1.name).Items(M2.name).Items(M3.Name).Items(M4.Name).Items(M5.Name).Gettype().GetProperty("Items")
                                    If P5 IsNot Nothing Then
                                        output.show(M5.text & "-" & M5.name & "  " & "有五级子菜单")
                                        For Each M6 As object In ContextMenus(EL_MN).Items(M1.name).Items(M2.Name).Items(M3.Name).Items(M4.Name).Items(M5.Name).Items
                                            Dim P6 As System.Reflection.PropertyInfo = ContextMenus(EL_MN).Items(M1.name).Items(M2.name).Items(M3.Name).Items(M4.Name).Items(M5.Name).Items(M6.Name).Gettype().GetProperty("Items")
                                            If P6 IsNot Nothing Then
                                                output.show(M6.text & "-" & M6.name & "  " & "有六级子菜单")
                                                '复制一层循环,在此加入后修改

                                            Else
                                                output.show(M6.text & "-" & M6.name)
                                            End If
                                        Next
                                    Else
                                        output.show(M5.text & "-" & M5.name)
                                    End If
                                Next
                            Else
                                output.show(M4.text & "-" & M4.name)
                            End If
                        Next
                       
                    Else
                        output.show(M3.text & "-" & M3.name)
                    End If
                Next
            Else
                output.show(M2.text & "-" & M2.name)
            End If
        Next
    Else
        output.show(M1.text & "-" & M1.name)
    End If
Next
Next

 

 

 

 

 

 

 


图片点击可在新窗口打开查看此主题相关图片如下:获取快捷菜单.jpg
图片点击可在新窗口打开查看
[此贴子已经被作者于2014-8-19 17:48:08编辑过]

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


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


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


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2014/8/19 17:30:00 [只看该作者]

快捷菜单有特殊性,这个递归例子没有参考意义呢.

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


加好友 发短信
等级:二尾狐 帖子:521 积分:4784 威望:0 精华:0 注册:2014/1/16 16:55:00
  发帖心情 Post By:2014/8/19 17:49:00 [只看该作者]

快捷菜单没办法写递归

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


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

 可以写,肯定可以写。

 

 不过,你直接用循环的效率肯定比写递归要好得多。

 

 菜单递归例子

 

 http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=55466&skin=0

 


 回到顶部