以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  ListView 对关联表不行吗  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=92414)

--  作者:yifan3429
--  发布时间:2016/11/2 22:55:00
--  ListView 对关联表不行吗
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
lvw.View = ViewMode.Details
\'lvw.Images.AddSmallImage("Man", "Man.ico") \'添加代表男性的图标
\'lvw.Images.AddSmallImage("Woman", "Woman.ico") \'添加代表女性的图标
Dim cls() As String = {"产品名","长","宽","厚","主材工艺","数量"} \'定义列名
Dim wds() As String = {160,60,60,60,160,40} \'定义列宽
For i As Integer = 0 To  cls.Length - 1  \'增加列
    Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
    c.Text = cls(i) \'指定列标题
    c.Name = cls(i) \'指定列名
    c.Width = wds(i) \'指定列宽
Next
For Each dr As DataRow In DataTables("订单表.订单明细").DataRows \'从数据表中提取数据
    Dim vr As  WinForm.ListViewRow =  lvw.Rows.Add() \'增加一行
    For Each cl As String In cls \'逐列取值
        vr(cl) = dr(cl)
    Next
    \'If dr("性别") = "男" Then \'设置分组
    \'vr.ImageKey = "Man"
    \'Else
    \'vr.ImageKey = "Woman"
    \'End If
    vr.Tag= dr \'将DataRow赋值给ListViewRow的Tag属性,将二者联系起来
Next


会提示 ---------------------------
提示
---------------------------
不存在名称为"订单表.订单明细"的DataTable!
---------------------------
确定   
---------------------------


--  作者:有点蓝
--  发布时间:2016/11/2 23:12:00
--  
For Each dr As Row In Tables("订单表.订单明细").Rows \'从数据表中提取数据
    Dim vr As  WinForm.ListViewRow =  lvw.Rows.Add() \'增加一行
    For Each cl As String In cls \'逐列取值
        vr(cl) = dr(cl)
    Next
    \'If dr("性别") = "男" Then \'设置分组
    \'vr.ImageKey = "Man"
    \'Else
    \'vr.ImageKey = "Woman"
    \'End If
    vr.Tag= dr.DataRow \'将DataRow赋值给ListViewRow的Tag属性,将二者联系起来
Next

--  作者:yifan3429
--  发布时间:2016/11/2 23:57:00
--  
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
lvw.StopRedraw() \'停止绘制
lvw.Groups.Clear() \'清除原来的分组
lvw.Columns.Clear() \'清除原来的列
lvw.Rows.Clear() \'清除原来的行
lvw.Images.Clear() \'清除原来的图片
lvw.View = ViewMode.Details \'显示模式为详细信息
Dim cls() As String = {"产品名","长","宽","厚","主材工艺","数量"}   \'定义列名
Dim wds() As Integer = {160,60,60,60,200,40} \'定义列宽
For i As Integer = 0 To  cls.Length - 1  \'增加列
    Dim c As WinForm.ListViewColumn = lvw.Columns.Add()
    c.Name = cls(i) \'指定列名
    c.Text = cls(i) \'指定标题,这里标题和列名相同
    c.Width = wds(i) \'指定列宽
Next
For Each zh As String In Tables("订单表.订单明细").GetValues("房间") \'增加分组
    Dim grp As WinForm.ListViewGroup = lvw.Groups.Add()
    grp.Name = zh
    grp.Text = zh
Next
For Each dr As DataRow In Tables("订单表.订单明细").DataRows
    \'Dim Key As String = dr("图标")
    Dim r As  WinForm.ListViewRow =  lvw.Rows.Add() \'增加一行
    lvw.Images.AddImage(Key, Key & ".ico", Key & "48.ico") \'添加代表这个国家的一对图标
    \'r.ImageKey = Key \'指定图标键值
    r.Group = dr("房间") \'指定所属分组
    For Each cl As String In cls \'逐列取值
        Select Case cl
            \'Case "人口","面积" \'如果是人口列或面积列
                \'r(cl) = format(dr(cl),"#,000") \'则显示千位分割符号
            Case Else
                r(cl) = dr(cl)
        End Select
    Next
Next
lvw.ResumeRedraw() \'恢复绘制





---------------------------
错误
---------------------------
编译错误:“GetValues”不是“Table”的成员。



错误代码:For Each zh As String In Tables("订单表.订单明细").GetValues("房间") \'增加分组
---------------------------
确定   
---------------------------


--  作者:有点蓝
--  发布时间:2016/11/3 8:37:00
--  
For Each zh As String In DataTables("订单明细").GetValues("房间","订单编号=\'" & Tables("订单表").Current("订单编号") & "\'") \'增加分组
    Dim grp As WinForm.ListViewGroup = lvw.Groups.Add()
    grp.Name = zh
    grp.Text = zh
Next
For Each dr As Row In Tables("订单表.订单明细").Rows
    \'Dim Key As String = dr("图标")
    Dim r As  WinForm.ListViewRow =  lvw.Rows.Add() \'增加一行
    lvw.Images.AddImage(Key, Key & ".ico", Key & "48.ico") \'添加代表这个国家的一对图标
    \'r.ImageKey = Key \'指定图标键值
    r.Group = dr("房间") \'指定所属分组
    For Each cl As String In cls \'逐列取值
        Select Case cl
            \'Case "人口","面积" \'如果是人口列或面积列
                \'r(cl) = format(dr(cl),"#,000") \'则显示千位分割符号
            Case Else
                r(cl) = dr(cl)
        End Select
    Next
Next



--  作者:有点蓝
--  发布时间:2016/11/3 8:38:00
--  
好好理解一下table和datatable