以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]添加菜单 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=120818) |
||||
-- 作者:blsu33 -- 发布时间:2018/6/24 17:45:00 -- [求助]添加菜单 老师, 希望用for each 逐行一次添加菜单(因为还有其他代码原因,不想通过递归添加,因为还有其他代码是for each 按照行生成的) 可以看到,到第三级顺序 就不对了,如何能按照for each 逐行 添加上菜单
[此贴子已经被作者于2018/6/24 17:49:30编辑过]
|
||||
-- 作者:有点色 -- 发布时间:2018/6/24 20:25:00 -- Dim Striptab As WinForm.Strip= e.Form.Strips.Add("ca", StripTypeEnum.MainMenu) \'添加菜单按钮分割线 Dim DT As DataTable=DataTables("表A") Dim levels As new List(of object) levels.add(striptab) For Each dr1 As DataRow In DataTables("表A").Select("", "menuid") Select Case dr1("mentype") Case "StripItemTypeEnum.MenuItem" For i As Integer = levels.count-1 To 0 Step -1 If dr1("menuid").contains(levels(i).name) Then Dim obj = levels(i).Items.Add(dr1("menuid"),dr1("poutcaption"),dr1("imgsmlt"),val(dr1("mentype"))) levels.add(obj) Exit For End If Next End Select Next |
||||
-- 作者:blsu33 -- 发布时间:2018/6/24 21:24:00 -- 老师 , 好久不见了,代码好用,但是放到我的例子中,就不行了,没办法,烦您再给看看。
|
||||
-- 作者:blsu33 -- 发布时间:2018/6/24 21:28:00 -- 我写的只能生成到二级,按照您给的例子,怎么写进去呢,标注颜色是第一次向您求助的部分? Dim e =args(0) Dim pnl As WinForm.Panel=args(1) Dim Striptab As WinForm.Strip Dim StriptabName As String=pnl.name.Replace("pnl","menu") If forms("serevmain").Strips.Contains(StriptabName) Then forms("serevmain").Strips.Remove(StriptabName) End If Dim dt As DataTable=Functions.Execute("tablloading","usperation") Select Case pnl.name.split("_")(0) Case "toolpnl" Striptab= FormS("serevmain").Strips.Add(StriptabName, StripTypeEnum.MainMenu) Striptab.Items.Add(StriptabName.replace("toolmenu","gb_"),"","Tools_exit.png",StripItemTypeEnum.Button) Striptab.Items(StriptabName.replace("toolmenu","gb_")).DisplayText = False Striptab.Items(StriptabName.replace("toolmenu","gb_")).DockToRight = True \'靠右停放 Case "findpnl" Striptab= FormS("serevmain").Strips.Add(StriptabName, StripTypeEnum.ToolBar) Case "stripnl" Striptab= FormS("serevmain").Strips.Add(StriptabName, StripTypeEnum.StatusBar) End Select pnl.basecontrol.controls.add(Striptab.basecontrol) \'添加菜单按钮分割线 Dim drsbj As List (of DataRow) drsbj=dt.Select(pnl.name.split("_")(0) & "=true" & " and id=\'"& pnl.name.split("_")(2) &"\'","itmoder") If drsbj.count>0 Then Dim i1 As Integer=0 For Each dr1 As DataRow In drsbj Select Case dr1("mentype") Case "StripItemTypeEnum.Separator" Striptab.Items.Add(pnl.name.Replace("pnl","Separator" & i1 ),"","",StripItemTypeEnum.Separator) Case "StripItemTypeEnum.MenuItem" Dim drslsb As DataRow=lsb("readrules").find("tbltname=\'zamenuset\' And tblcolid=\'menuid\'") If drslsb IsNot Nothing Then Dim count As Integer= 0 Dim count2 As Integer= 0 For i As Integer = 0 To drslsb("colong").length - 1 count += val(drslsb("colong").chars(i)) count2=val(drslsb("colong").chars(i)) If count <= dr1("menuid").length Then Dim str As String = dr1("menuid").Substring(0,count) \'Dim drf As DataRow=dt.find(pnl.name.split("_")(0) & "=true And id=\'" & pnl.name.split("_")(2) & "\' And mentype=\'"& dr1("mentype") &"\' And menuid like\'"& str &"%\' And menuid <> \'"& str &"\'") \'Dim drf As DataRow=dt.find(pnl.name.split("_")(0) & "=true And id=\'" & pnl.name.split("_")(2) & "\' And mentype=\'"& dr1("mentype") &"\' And menuid =\'"& str &"\'") \'\'If drf IsNot Nothing Then Dim drf2 As DataRow=dt.find(pnl.name.split("_")(0) & "=true And id=\'" & pnl.name.split("_")(2) & "\' And mentype=\'"& dr1("mentype") &"\' And menuid =\'"& str.SubString(0,str.length-count2) &"\'") If drf2 IsNot Nothing Then If Striptab.Items.Contains(str.SubString(0,str.length-count2))=False Then Dim dr2 As DataRow=dt.find("menuid=\'"& str.SubString(0,str.length-count2) &"\'") If dr2 IsNot Nothing Then Striptab.Items.Add(str.SubString(0,str.length-count2),dr2("poutcaption"),dr2("imgsmlt"),val(dr2("mentype")))\'还要改下 End If Else Dim Stripitm As WinForm.StripItem= Striptab.Items(str.SubString(0,str.length-count2)) If Stripitm.Items.Contains(str)=False Then Dim dr2 As DataRow=dt.find("menuid=\'"& str &"\'") If dr2 IsNot Nothing Then Stripitm.Items.Add(str,dr2("poutcaption"),dr2("imgsmlt"),val(dr2("mentype"))) End If End If End If Else If Striptab.Items.Contains(str)=False Then Dim dr2 As DataRow=dt.find("menuid=\'"& str &"\'") If dr2 IsNot Nothing Then Striptab.Items.Add(str,dr2("poutcaption"),dr2("imgsmlt"),val(dr2("mentype"))) End If End If End If End If Next End If Case "StripItemTypeEnum.Label","StripItemTypeEnum.SplitButton","StripItemTypeEnum.Button" Striptab.Items.Add(dr1("menuid"),dr1("poutcaption"),dr1("imgsmlt"),val(dr1("mentype"))) Striptab.Items(dr1("menuid")).DisplayText = True End Select i1=i1+1 Next End If [此贴子已经被作者于2018/6/24 21:40:14编辑过]
|
||||
-- 作者:有点甜 -- 发布时间:2018/6/24 23:40:00 -- 你发的例子和你的描述不符,你的例子要做到什么效果? |
||||
-- 作者:blsu33 -- 发布时间:2018/6/24 23:46:00 -- 老师, 3楼 顺序添加图片上的菜单控件 ,根据表A的前两列生成的,因为 有BTN 有分割线还有菜单,那么希望按照表列的顺序,FOR EACH 逐行生成。 [此贴子已经被作者于2018/6/24 23:49:06编辑过]
|
||||
-- 作者:有点甜 -- 发布时间:2018/6/25 9:19:00 -- Dim Striptab As WinForm.Strip= e.Form.Strips.Add("", StripTypeEnum.MainMenu) \'添加菜单按钮分割线 Dim DT As DataTable=DataTables("表A") Dim levels As new List(of object) levels.add(striptab) For Each dr1 As DataRow In DataTables("表A").Select("", "menuid") Dim T = Nothing Select Case dr1("mentype") Case "StripItemTypeEnum.MenuItem" t = StripItemTypeEnum.MenuItem Case "StripItemTypeEnum.Button" \'t = StripItemTypeEnum.Button t = StripItemTypeEnum.MenuItem Case "StripItemTypeEnum.Separator" t = StripItemTypeEnum.Separator End Select If t IsNot Nothing Then For i As Integer = levels.count-1 To 0 Step -1 If dr1("menuid").contains(levels(i).name) Then Dim obj = levels(i).Items.Add(dr1("menuid"),dr1("poutcaption"),dr1("imgsmlt"),t) obj.text = dr1("poutcaption") levels.add(obj) Exit For End If Next End If Next |