以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  ListView1  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=102568)

--  作者:yaojun
--  发布时间:2017/6/22 13:09:00
--  ListView1
ListView1中显示了几个按钮,例如“生产订单”,“客户资料”,“BOM表”等若干按钮,请求如何单击或者是双击打开对应的窗口,比如双击按钮“生产订单”就打开窗口名称为“生产订单”的窗口,求代码。
--  作者:有点蓝
--  发布时间:2017/6/22 14:25:00
--  

--  作者:yaojun
--  发布时间:2017/6/22 15:57:00
--  
以下是引用有点蓝在2017/6/22 14:25:00的发言:

 

ListView1

可是我的ListView1里面的按钮是用专家坐堂里面的框架设计的代码动态生成,这个好像不行哦。

\'生成任务栏导航
\'1生成页面
Dim r2 As List(of String()) = DataTables("大纲管理").GetValues("名称|图标","","顺序")
\'遍历大纲
For Each rl As String() In r2
    \'大纲权限过滤
    If User.Type<>UserTypeEnum.Developer Then
        Dim qx As String = DataTables("单据权限").GetComboListString("大纲","大纲 = \'" & rl(0) & "\' and  用户名称 = \'" & User.Name & "\'")
        If qx.IndexOf(rl(0))<> -1 Then
            \'添加页面
            Dim Page As WinForm.TopicPage
            Page=Forms("首页").Controls("TopicBar1").Pages.Add(rl(0),rl(0),rl(1))
            \'2添加任务
            Dim r1 As List(of String()) = DataTables("模块管理").GetValues("模块名称|图标","大纲 =\'" & rl(0) & "\'","顺序")
            For Each r1l As String() In r1
                \'模块过滤
                Dim mk As String = DataTables("单据权限").GetComboListString("模块","大纲=\'" & rl(0) & "\'and 模块 = \'" & r1l(0) & "\' and  用户名称 = \'" & User.Name & "\'")
                If mk.IndexOf(r1l(0))<> -1 Then
                    Page.Links.Add(r1l(0),r1l(0),r1l(1))
                End If
            Next
        End If
    Else
        Dim Page As WinForm.TopicPage
        Page=Forms("首页").Controls("TopicBar1").Pages.Add(rl(0),rl(0),rl(1))
        \'2添加任务
        Dim r1 As List(of String()) = DataTables("模块管理").GetValues("模块名称|图标","大纲 =\'" & rl(0) & "\'","顺序")
        For Each r1l As String() In r1
            Page.Links.Add(r1l(0),r1l(0),r1l(1))
        Next
    End If
Next

\'添加单据
Dim tp As WinForm.TopicBar = e.Form.Controls("TopicBar1")
dagang = tp.Pages(0).Name \'大纲
mokuai = tp.Pages(0).Links(0).Name \'模块
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
lvw.Groups.Clear() \'清除原来的分组
lvw.Rows.Clear() \'清除原来的行
lvw.Images.Clear() \'清除原来的图片
lvw.View = ViewMode.LargeIcon
lvw.Images.LargeSize = New Size(32,32)
\'获取模块包含的小类
Dim fenzu As List(of String)= DataTables("模块分类").GetValues("模块小类","大纲 = \'" & dagang & "\' and 模块名称 = \'" & mokuai & "\' ","顺序")
For Each fz As String In fenzu
    If User.Type<>UserTypeEnum.Developer Then
        Dim qx As String = DataTables("单据权限").GetComboListString("分类","大纲=\'" & dagang & "\' and 模块=\'" & mokuai & "\' and 分类 = \'" & fz & "\' and  用户名称 = \'" & User.Name & "\'")
        If qx.IndexOf(fz) <> -1 Then
            \'添加分组
            Dim vg As  WinForm.ListViewGroup = lvw.Groups.add()
            vg.Name=fz
            vg.text= "☆☆☆ [ " & fz & " ]"
            \'获取单据名称和图标,逐个添加
            Dim DanJ  As List(of String())= DataTables("窗体发布").GetValues("单据|图标","大纲=\'" & dagang & "\' and  模块=\'" & mokuai & "\' and 分类=\'" & fz & "\'","顺序")
            For Each dj As String() In DanJ
                Dim qx1 As String = DataTables("单据权限").GetComboListString("单据", "大纲=\'" & dagang & "\' and  模块=\'" & mokuai & "\' and 分类=\'" & fz & "\' and 单据 = \'" & dj(0) & "\' and  用户名称 = \'" & User.Name & "\'")
                If qx1.IndexOf(dj(0)) <> -1 Then
                    Dim r As WinForm.ListViewRow = lvw.Rows.add()
                    r.Text=dj(0)
                    r.Group=fz
                    lvw.Images.AddImage(dj(1),dj(1) , dj(1)) \'图标
                    r.ImageKey=dj(1)
                End If
            Next
        End If
    Else
        \'添加分组
        Dim vg As  WinForm.ListViewGroup = lvw.Groups.add()
        vg.Name=fz
        vg.text= "☆☆☆ [ " & fz & " ]"
        \'获取单据名称和图标,逐个添加
        Dim DanJ  As List(of String())= DataTables("窗体发布").GetValues("单据|图标","大纲=\'" & dagang & "\' and  模块=\'" & mokuai & "\' and 分类=\'" & fz & "\'","顺序")
        For Each dj As String() In DanJ
            Dim r As WinForm.ListViewRow = lvw.Rows.add()
            r.Text=dj(0)
            r.Group=fz
            lvw.Images.AddImage(dj(1),dj(1) , dj(1)) \'图标
            r.ImageKey=dj(1)
        Next
    End If
Next

[此贴子已经被作者于2017/6/22 15:59:32编辑过]

--  作者:有点色
--  发布时间:2017/6/22 16:17:00
--  

 一样,弹出的是什么值?


--  作者:yaojun
--  发布时间:2017/6/22 16:33:00
--  

现在是打开的主窗口,但是我希望打开独立窗口

Dim lr As WinForm.ListViewRow = e.Sender.Current
Dim b,ck As String
Dim r2 As List(of DataRow) = DataTables("窗体发布").SQLSelect("大纲 = \'" & dagang & "\' and 模块=\'" & mokuai & "\' and 分类=\'" & lr.Group & "\' and 单据 = \'" & lr.Text & "\'")
For Each r As DataRow In r2
    If r.IsNull("窗口表") Or r.IsNull("后台名称") Then
        b=lr.Text
        ck=b
    Else
        b=r("窗口表")
        ck=r("后台名称")
        BaseMainForm.Controls("MainPages").Controls(b).text = lr.Text
    End If
Next
For Each c As WinForm.Form In Forms
    If c.Name=ck Then
        Forms(c.name).show()
        Exit For
    End If
Next
For Each biao As Table In Tables
    If biao.Name=b Then
        MainTable=Tables(b)
        Exit For
    End If
Next


--  作者:有点色
--  发布时间:2017/6/22 16:39:00
--  

 1、你的表结构是怎样的?

 

 2、如何根据 点击的节点 lr.Text 查找到窗口名?


--  作者:yaojun
--  发布时间:2017/6/22 16:55:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:赢管.table


--  作者:有点色
--  发布时间:2017/6/22 17:39:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:赢管.table


--  作者:yaojun
--  发布时间:2017/6/22 18:20:00
--  

谢谢有点色老师,以上双击还是打开表,不能打开独立窗口,求老师再帮忙看看,辛苦了老师

以上修改从窗口编辑里打开没有问题,但是从首页里打开就只显示表,不显示窗口了,因为很多窗口是查询窗口,所以不需要显示表,只要显示窗口就行,老师辛苦。

[此贴子已经被作者于2017/6/22 18:25:59编辑过]

--  作者:yaojun
--  发布时间:2017/6/22 18:56:00
--  

有点色老师,谢谢了,解决了

但是请老师帮忙改改如下代码:

Forms("首页").Controls("TabControl1").SelectedIndex = 1
\'获取大纲 模块
dagang = e.Page.Name
mokuai = e.Link.Name
\'初始化listview
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
lvw.Groups.Clear() \'清除原来的分组
lvw.Rows.Clear() \'清除原来的行
lvw.Images.Clear() \'清除原来的图片
lvw.View = ViewMode.LargeIcon
lvw.Images.LargeSize = New Size(32,32)
\'获取大纲中模块包含的小类
Dim fenzu As List(of String)= DataTables("模块分类").GetValues("模块小类","大纲 = \'" & dagang & "\' And 模块名称 = \'" & mokuai & "\'","顺序")
\'遍历小类
For Each fz As String In fenzu
    \'帐号不为开发者情况
    If User.Type<>UserTypeEnum.Developer Then
        \'获取用户权限表数据
        Dim qx As String = DataTables("单据权限").GetComboListString("分类","大纲=\'" & dagang & "\' and 模块=\'" & mokuai & "\' and 分类 = \'" & fz & "\' and  用户名称 = \'" & User.Name & "\'")
        If qx.IndexOf(fz) <> -1 Then
            \'添加分组
            Dim vg As  WinForm.ListViewGroup = lvw.Groups.add()
            vg.Name=fz
            vg.text= "☆☆☆ [ " & fz & " ]"
            \'获取单据名称和图标,逐个添加
            Dim DanJ  As List(of String())= DataTables("窗体发布").GetValues("单据|图标","大纲=\'" & dagang & "\' and  模块=\'" & mokuai & "\' and 分类=\'" & fz & "\'","顺序")
            \'添加分组中的单据
            For Each dj As String() In DanJ
                Dim qx1 As String = DataTables("单据权限").GetComboListString("单据", "大纲=\'" & dagang & "\' and 模块=\'" & mokuai & "\' and 分类 = \'" & fz & "\'and 单据 = \'" & dj(0) & "\' and  用户名称 = \'" & User.Name & "\'")
                If qx1.IndexOf(dj(0)) <> -1 Then
                    Dim r As WinForm.ListViewRow = lvw.Rows.add()
                    r.Text=dj(0)
                    r.Group=fz
                    lvw.Images.AddImage(dj(1),dj(1) , dj(1)) \'图标
                    r.ImageKey=dj(1)
                End If
            Next
        End If
        \'开发者情况
    Else
        \'添加分组
        Dim vg As  WinForm.ListViewGroup = lvw.Groups.add()
        vg.Name=fz
        vg.text= "☆☆☆ [ " & fz & " ]"
        \'获取单据名称和图标,逐个添加
        Dim DanJ  As List(of String())= DataTables("窗体发布").GetValues("单据|图标","大纲=\'" & dagang & "\' and  模块=\'" & mokuai & "\' and 分类=\'" & fz & "\'","顺序")
        For Each dj As String() In DanJ
            Dim r As WinForm.ListViewRow = lvw.Rows.add()
            r.Text=dj(0)
            r.Group=fz
            lvw.Images.AddImage(dj(1),dj(1) , dj(1)) \'图标
            r.ImageKey=dj(1)
        Next
    End If
Next


Dim dt As Date = Date.Today.AddDays(1)
Select Case e.Link.Name
    Case "产品展览"
    Forms("首页").Controls("TabControl1").SelectedIndex = 2
      Dim lvww As WinForm.ListView = e.Form.Controls("ListView2")
lvww.StopRedraw() \'暂停绘制
lvww.Rows.Clear() \'清除原来的行
lvww.Images.Clear() \'清除原来的图片
lvww.View = ViewMode.LargeIcon \'显示模式为 大图标
lvww.Images.LargeSize = New Size(130,120) \'定义大图标尺寸
For Each dr As DataRow In DataTables("表A").DataRows \'从数据表中提取数据
    Dim Key As String = dr("图片") \'获取此员工的照片文件
    lvw.Images.AddLargeImage(Key, Key) \'添加照片,直接用文件名作为图片键值
    Dim vr As  WinForm.ListViewRow =  lvww.Rows.Add() \'增加一行
    vr.Text = dr("名称")  \'设置标题
    vr.ImageKey = Key \'设置图片键值
vr.Tag= dr \'将DataRow赋值给ListViewRow的Tag属性,将二者联系起来
Next
lvw.ResumeRedraw() \'恢复绘制        
End Select

 

按下后Forms("首页").Controls("TabControl1").SelectedIndex = 2 不能显示,好像和Forms("首页").Controls("TabControl1").SelectedIndex = 1冲突了,请求修改