以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]FileManager 问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=89250)

--  作者:wangyinming
--  发布时间:2016/8/18 9:21:00
--  [求助]FileManager 问题
想让窗口中所有的FileManager控件(1~7),按用户组显示各命令。

一个一个写太麻烦了吧,有简化的办法吗?
Dim fm As WinForm.FileManager = e.Form.Controls("FileManager1")
Dim fm2 As WinForm.FileManager = e.Form.Controls("FileManager2")
Dim fm3 As WinForm.FileManager = e.Form.Controls("FileManager3")
Dim fm4 As WinForm.FileManager = e.Form.Controls("FileManager4")
Dim fm5 As WinForm.FileManager = e.Form.Controls("FileManager6")
Dim fm6 As WinForm.FileManager = e.Form.Controls("FileManager7")


If User.Group = "查询" Then
    fm.DeleteCommand.Visible = False
    fm.ClearCommand.Visible = False
    fm.Addcommand.visible = False
    fm.AddFolderCommand.visible = False
    fm.SaveAsCommand.visible = False
    
    
Else
    If User.Group = "文件管理" Then
        fm.DeleteCommand.Visible = False
    Else
        
        If User.Group = "特定用户" Then
            fm.DeleteCommand.Visible = False
            fm.ClearCommand.Visible = False
            fm.Addcommand.visible = False
            fm.AddFolderCommand.visible = False
        End If
    End If
End If

--  作者:大红袍
--  发布时间:2016/8/18 9:27:00
--  
For i As Integer = 1 To 7
    Dim fm As WinForm.FileManager = e.Form.Controls("FileManager" & i)
    If User.Group = "查询" Then
        fm.DeleteCommand.Visible = False
        fm.ClearCommand.Visible = False
        fm.Addcommand.visible = False
        fm.AddFolderCommand.visible = False
        fm.SaveAsCommand.visible = False
       
       
    Else
        If User.Group = "文件管理" Then
            fm.DeleteCommand.Visible = False
        Else
           
            If User.Group = "特定用户" Then
                fm.DeleteCommand.Visible = False
                fm.ClearCommand.Visible = False
                fm.Addcommand.visible = False
                fm.AddFolderCommand.visible = False
            End If
        End If
    End If
next