以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何获取A表字段内容来作为创建B临时表的字段名  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=185154)

--  作者:lanbor
--  发布时间:2023/2/7 18:56:00
--  如何获取A表字段内容来作为创建B临时表的字段名
拜请教专家:
如何获取A表字段内容来作为创建B临时表的字段名,并创建一个B临时表

一、条件:
A表有个字段“产品名称”,里面有内容 “电脑、电视、电话、冰箱

二、需求:
需要创建一个B临时表,
    每次打开应用界面时,B临时表的字段数量,会随着 A表 产品名称内容增加而增加;
   以这样的形式来创建一个空白表B临时表
   然后这个B临时表,可以被操作,不需要保存!

请教专家指点具体代码,
感谢感谢!


--  作者:有点蓝
--  发布时间:2023/2/7 20:21:00
--  
参考:http://www.foxtable.com/webhelp/topics/0679.htm,看示例二
--  作者:lanbor
--  发布时间:2023/2/8 0:02:00
--  临时表问题再请教
我通过学习http://www.foxtable.com/webhelp/topics/0679.htm,制作生成的临时表,
出现的现象是:在设计窗口的Table1 里面只有”标题“,没有内容
临时表的标题和内容都保存在后台去了,
请教需要如何解决?
动态表生成代码如下:
Dim dtb As New DataTableBuilder("TabB")
dtb.Clear
dtb.AddDef("itemID", GetType(Integer), 8, "", "产品_配件_ID") \'定义新表的标题
For Each v As String In DataTables("product_platform").sqlGetValues("plan_name_spec")
    dtb.AddDef(v, GetType(String), 1) \'用平台名称内容来作为临时表的标题
Next
dtb.Build()
\'----------字段名称加载完成
For Each v As Integer In DataTables("Product_PartList").GetValues("itemID")
    Dim dr1 As Row = Tables("TabB").AddNew()
    dr1("itemID") = v \'把配件名称中的ItmeID内容写入临时表的ItemID 字段
Next
MainTable = Tables("TabB")
Tables(e.Form.Name & "_Table1").DataSource = dtb.BuildDataSource()
[此贴子已经被作者于2023/2/8 23:01:08编辑过]

--  作者:有点蓝
--  发布时间:2023/2/8 8:34:00
--  
Dim dtb As New DataTableBuilder("TabB")
dtb.AddDef("itemID", GetType(Integer), 8, "", "产品_配件_ID") \'定义新表的标题
For Each v As String In DataTables("product_platform").sqlGetValues("plan_name_spec")
    dtb.AddDef(v, GetType(String), 1) \'用平台名称内容来作为临时表的标题
Next
Tables(e.Form.Name & "_Table1").DataSource = dtb.BuildDataSource()
\'----------字段名称加载完成
For Each v As Integer In DataTables("Product_PartList").GetValues("itemID")
    Dim dr1 As Row = Tables(e.Form.Name & "_Table1").AddNew()
    dr1("itemID") = v \'把配件名称中的ItmeID内容写入临时表的ItemID 字段
Next


--  作者:lanbor
--  发布时间:2023/2/10 9:17:00
--  临时表问题再再请教!
感谢专家指教,临时表字段内容能在Table1中正常显示了.

再请教:如何设置由临时表传入的字段内容的颜色变成红色?

----如何在下面代码中追加语句?-----
Tables(e.Form.Name & "_Table1").DataSource = dtb.buildDatasource()
Tables(e.Form.Name & "_Table1").AllowEdit = True
Tables(e.Form.Name & "_Table1").DefaultColWidth = 80
Tables(e.Form.Name & "_Table1").Cols(0).Width = 30
Tables(e.Form.Name & "_Table1").Cols(1).Width = 150
Tables(e.Form.Name & "_Table1").Cols(2).Width = 200
Tables(e.Form.Name & "_Table1").Cols.Frozen = 3
\'----------字段名称加载完成
For Each v As String() In DataTables("Product_PartList").GetValues("itemID|part_name|Specification","use_ok=\'Y\'","itemID")
    Dim dr1 As Row = Tables(e.Form.Name & "_Table1").AddNew()
    dr1("itemID") = v(0) 
    dr1("part_name") = v(1)
    dr1("Specification") = v(2)
Next
For Each r1 As Row In Tables(e.Form.Name & "_Table1").Rows 
    DataTables("Plan_MatchingList").LoadFilter = "item_id=" & r1("itemID") 
    DataTables("Plan_MatchingList").Load
    Tables("Plan_MatchingList").Sort = "plan_name_no"
    For Each cl As Col In Tables(e.Form.Name & "_Table1").Cols 
        r2 = Tables("Plan_MatchingList").FindRow("[plan_name_spec] =\'" & cl.name & "\'") 
        If r2 > 0 Then
            r1(cl.name) = True
        Tables(e.Form.Name & "_Table1").SetHeaderCellForeColor(cl.name, Color.Red)\'能把有内容的字段标题变更红色
        End If
        
    Next
Next

再请教:如何设置由临时表传入的字段内容的文字颜色变成红色?
感谢感谢!


[此贴子已经被作者于2023/2/10 13:07:16编辑过]

--  作者:有点蓝
--  发布时间:2023/2/10 9:29:00
--  
把窗口表设置为sqltable,到窗口表事件drawcell事件处理:http://www.foxtable.com/webhelp/topics/0656.htm