遇到一个菜单问题,无法循环判断并且剔除不想显示的菜单了。或者有更好的展现方式,谢谢版主!
此主题相关图片如下:pic_2019-05-10_10-49-17.jpg
这是菜单表,我添加了一个列:菜单子项,用来在tv中展现,而不要在上方ribbon菜单中体现,但是如下图,ribbon会有,我循环判断出错,不知道怎么办,或者版主有更好的办法:
此主题相关图片如下:1.jpg
之前的代码如下:
If RibbonTabs.Count > 5 Then
Return
Else
Dim drs As List(Of DataRow)
drs = DataTables("菜单表").Select("[功能区] Like '*'","OrderID")
For Each dr As DataRow In drs
Dim tab As New RibbonMenu.Tab(dr("功能区"))
If not RibbonTabs.Contains(dr("功能区")) Then
tab.Text = dr("功能区")
RibbonTabs.Add(tab)
End If
Next
For Each dr As DataRow In drs
Dim rg As New RibbonMenu.group(dr("功能组"))
If not RibbonTabs(dr("功能区")).groups.Contains(dr("功能组")) Then
rg.Text = dr("功能组")
RibbonTabs(dr("功能区")).Groups.Add(rg)
End If
Next
For Each dr As DataRow In drs
If dr("项类型") = "RibbonMenu.Separator" Then
Dim rb As new RibbonMenu.Separator(dr("功能项"))
RibbonTabs(dr("功能区")).Groups(dr("功能组")).Items.Add(rb)
Else
Dim itm As RibbonMenu.RibbonItem
For Each itm In RibbonTabs("功能区").Groups("功能组").Items
If Typeof itm Is RibbonMenu.Button Then
If itm.Text <> dr("功能项") Then
Dim rb As New RibbonMenu.Button(dr("功能项"))
rb.Text = dr("功能项")
rb.LargeImage = GetImage(ProjectPath & "Images\" & dr("图标"))
rb.TextImageRelation = TextImageRelationEnum.ImageAboveText
RibbonTabs(dr("功能区")).Groups(dr("功能组")).Items.Add(rb)
End If
End If
Next
End If
Next
End If
窗体中的代码:
'动态生成目录树
Dim gnq As String = RibbonTabs.SelectedTab.Name
Functions.Execute("ChangeTV",e.Form,gnq)
ChangeTV代码:
'动态切换树
Dim tv1 As WinForm.TreeView = Args(0).Controls("TreeView1")
tv1.BuildTree("菜单表","功能项|功能子项","功能区 = '"& Args(1) &"'","OrderID ASC")
tv1.ExpandAll()