结合权限的代码设置后,老是多添加一组出来,如图
添加分组的代码标红,老是自动添加一组名为Default的组出来,怎么去掉呢?
此主题相关图片如下:qq图片20150516152535.jpg
Dim qcr As DataRow = DataTables("用户表").SQLFind("用户名 = '" & _User & "'")
Functions.Execute("动态添加lable")
e.Form.BackColor = SystemColors.GradientInactiveCaption
Dim lvw As WinForm.ListView = Forms("主界面").Controls("ListView1")
Dim Nav As WinForm.NavBar = Forms("主界面").Controls("NavBar1")
If _User <> "管理员"
'隐藏未编辑项目
For Each pg As WinForm.NavPage In Nav.NavPages
Dim pgn As String = pg.Name
Dim dr As DataRow = DataTables("授权表").SQLFind("模块名称 = '" & pgn & "' And 对象窗口 is NUll And 对象名称 Is Null")
If dr IsNot Nothing
Dim uss As String = dr("被授权人")
If uss.Contains(_User) = True OrElse uss.Contains(qcr("职位")) = True
pg.Visible = True
Else
pg.Visible = False
End If
Else
pg.Visible = False
End If
Next
''''-----------------------
lvw.StopRedraw() '暂停绘制
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
lvw.View = ViewMode.LargeIcon '显示模式为大图标
lvw.Images.LargeSize = New Size(32,32) '定义大图标尺寸
lvw.MultiSelect = False
Dim nms As List(of String) = DataTables("导航菜单").GetValues("模块名称")
For Each nm As String In nms '添加分组
Dim grp As WinForm.ListViewGroup = lvw.Groups.Add()
'====
Dim dr As DataRow = DataTables("授权表").SQLFind("模块名称 = '" & nm & "' And 对象窗口 is NUll And 对象名称 Is Null")
If dr IsNot Nothing
Dim uss As String = dr("被授权人")
If uss.Contains(_User) = True OrElse uss.Contains(qcr("职位")) = True
'MessageBox.show(nm)
grp.Name = nm
grp.Text = nm
End If
End If
'===
Next
For Each dr As DataRow In DataTables("导航菜单").DataRows '从数据表中提取数据
Dim vr As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
Dim Key As String = dr("图标地址")'获取此员工的照片文件
lvw.Images.AddLargeImage(key,key) '添加照片,直接用文件名作为图片键值
Dim ccr As DataRow = DataTables("授权表").SQLfind("对象窗口 = '" & dr("元素名称") & "' And 对象名称 is null")
If ccr IsNot Nothing
Dim uss As String = ccr("被授权人")
If uss.Contains(_User) = True OrElse uss.Contains(qcr("职位")) = True
vr.Group = dr("模块名称")
vr.Text = dr("元素名称") '设置标题
vr.ImageKey = key '设置图片键值
vr.ToolTipText = dr("功能概述")
End If
End If
Next
lvw.ResumeRedraw() '恢复绘制
'===========================================================
Else
lvw.StopRedraw() '暂停绘制
lvw.Rows.Clear() '清除原来的行
lvw.Images.Clear() '清除原来的图片
lvw.View = ViewMode.LargeIcon '显示模式为大图标
lvw.Images.LargeSize = New Size(32,32) '定义大图标尺寸
lvw.MultiSelect = False
Dim nms As List(of String) = DataTables("导航菜单").GetValues("模块名称")
For Each nm As String In nms '添加分组
Dim grp As WinForm.ListViewGroup = lvw.Groups.Add()
grp.Name = nm
grp.Text = nm
Next
For Each dr As DataRow In DataTables("导航菜单").DataRows '从数据表中提取数据
Dim vr As WinForm.ListViewRow = lvw.Rows.Add() '增加一行
Dim Key As String = dr("图标地址")'获取此员工的照片文件
lvw.Images.AddLargeImage(key,key) '添加照片,直接用文件名作为图片键值
vr.Group = dr("模块名称")
vr.Text = dr("元素名称") '设置标题
vr.ImageKey = key '设置图片键值
vr.ToolTipText = dr("功能概述")
Next
lvw.ResumeRedraw() '恢复绘制
End If