以下是引用有点色在2017/3/8 13:58:00的发言:
上传例子或者贴出代码
你要指定图片 b.LargeImage = getimage("d:\test.ico")
RibbonTabs.Clear
QAT.Items.Clear
ConfigBar.Items.Clear
Dim dt As DataTable = DataTables("菜单表")
For Each dr As DataRow In dt.DataRows
Select Case dr("类型")
Case "功能区"
Dim ntab As RibbonMenu.Tab
Dim ngrp As RibbonMenu.Group
Dim nmenu As Object
If RibbonTabs.Contains(dr("功能区")) Then
ntab = RibbonTabs(dr("功能区"))
Else
ntab = New RibbonMenu.Tab(dr("功能区"))
RibbonTabs.Add(ntab)
End If
If ntab.Groups.Contains(dr("功能组")) Then
ngrp = ntab.Groups(dr("功能组"))
Else
ngrp = New RibbonMenu.Group(dr("功能组"))
ntab.Groups.Add(ngrp)
End If
'编译一个生成不同菜单的函数
Functions.Remove("CreateMenu")
Dim Code As String = ""
Code = "Dim menu As New " & dr("菜单类型") & "(""" & dr("_Identify") & """)" & vbcrlf
Code = Code & "Return menu"
Functions.Add("CreateMenu", Code)
Functions.Complie()
nmenu = Functions.Execute("CreateMenu")
ntab.Text = dr("功能区")
ngrp.Text = dr("功能组")
nmenu.Text = dr("菜单标题")
nmenu.smallImage = getimage(dr("图标"))
ngrp.Items.Add(nmenu) '加入菜单
Case "快速访问栏"
If dr.Isnull("功能区") Then
'编译一个生成不同菜单的函数
Functions.Remove("CreateMenu")
Dim Code As String = ""
Code = "Dim menu As New " & dr("菜单类型") & "(""" & dr("菜单标题") & """)" & vbcrlf
Code = Code & "Return menu"
Functions.Add("CreateMenu", Code)
Functions.Complie()
Dim nmenu As Object = Functions.Execute("CreateMenu")
nmenu.Text = dr("菜单标题")
QAT.Items.Add(nmenu)
Else
'编译一个生成不同菜单的函数
Functions.Remove("CreateMenu")
Dim Code As String = ""
Code = "Dim menu As New " & dr("菜单类型") & "(""" & dr("_Identify") & """)" & vbcrlf
Code = Code & "Return menu"
Functions.Add("CreateMenu", Code)
Functions.Complie()
Dim nmenu As Object = Functions.Execute("CreateMenu")
nmenu.Text = dr("菜单标题")
QAT.Items(dr("功能区")).Items.Add(nmenu)
End If
Case "配置栏"
'编译一个生成不同菜单的函数
Functions.Remove("CreateMenu")
Dim Code As String = ""
Code = "Dim menu As New " & dr("菜单类型") & "(""" & dr("_Identify") & """)" & vbcrlf
Code = Code & "Return menu"
Functions.Add("CreateMenu", Code)
Functions.Complie()
Dim nmenu As Object = Functions.Execute("CreateMenu")
nmenu.Text = dr("菜单标题")
nmenu.smallImage = getimage(dr("图标"))
ConfigBar.Items.Add(nmenu)
End Select
Next