以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]窗口中二张表联动的问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=149228)

--  作者:huangfanzi
--  发布时间:2020/4/26 22:39:00
--  [求助]窗口中二张表联动的问题
    
表1的DataColChanged事件
Dim tb As WinForm.Table = e.Form.Controls("Table_表2")
Dim t As Table = tb.Table
t.Rows(CurrentTable.Current.Index)("选中标记") = e.DataRow("选中标记")

窗口中有二张表,我希望选择表1中的 选中标记(逻辑型),表2的对应行记录的 选中标记 也发生相应更改
用了以上代码,我如果在表1中一个一个点选,是可以实现想要的功能的,可我如果用 CTRL + D 的方法一次性更改表1中 选中标记 多条记录,表2中只能实现第一条记录联动,后面的就不变了,请老师看下,谢谢!

--  作者:有点蓝
--  发布时间:2020/4/26 23:11:00
--  
先看看:http://www.foxtable.com/webhelp/topics/1522.htm

Dim dr As DataRow = e.DataRow 
Select
 Case e.DataCol.Name 
    
Case "
选中标记" 
       dim dr as datarow = 
e.Form.Controls("Table_表2").table.datatable.find("关联列=‘" & e.DataRow("关联列") & "’")
if dr isnot nothing then
dr("选中标记") = e.DataRow("选中标记")
end if
End Select

--  作者:huangfanzi
--  发布时间:2020/4/26 23:23:00
--  
老师,二张表没有直接的关联列,唯一的关联就是在table表中的顺序,表1中的第一行与表2中的第一行是一对,以此累推,请问应该如何写代码
以下是二张表的代码,此二表已经被设置成禁止排序了,可以确保数据一但加载后顺序不会变了

If e.DataCol.Name = "选中标记" OrElse e.DataCol.Name = "数量" OrElse e.DataCol.Name = "时间" Then
    Dim bt As WinForm.Button = e.Form.Controls("Button_内转生成")
    If bt.Enabled = True
        Dim tb As WinForm.Table = e.Form.Controls("Table_内转入库")
        Dim t As Table = tb.Table
        t.Rows(CurrentTable.Current.Index)("选中标记") = e.DataRow("选中标记")
        t.Rows(CurrentTable.Current.Index)("数量") = e.DataRow("数量")
        t.Rows(CurrentTable.Current.Index)("时间") = e.DataRow("时间")
        t.Refresh
    End If
End If


If e.DataCol.Name = "选中标记" OrElse e.DataCol.Name = "数量" OrElse e.DataCol.Name = "时间" Then
    Dim bt As WinForm.Button = e.Form.Controls("Button_内转生成")
    If bt.Enabled = True
        Dim tb As WinForm.Table = e.Form.Controls("Table_内转出库")
        Dim t As Table = tb.Table
        t.Rows(CurrentTable.Current.Index)("选中标记") = e.DataRow("选中标记")
        t.Rows(CurrentTable.Current.Index)("数量") = e.DataRow("数量")
        t.Rows(CurrentTable.Current.Index)("时间") = e.DataRow("时间")
        t.Refresh
    End If
End If


图片点击可在新窗口打开查看此主题相关图片如下:11.jpg
图片点击可在新窗口打开查看

[此贴子已经被作者于2020/4/26 23:32:23编辑过]

--  作者:有点蓝
--  发布时间:2020/4/27 8:32:00
--  
还要保证加载的行数是一致的

If e.DataCol.Name = "选中标记" OrElse e.DataCol.Name = "数量" OrElse e.DataCol.Name = "时间" Then
    Dim bt As WinForm.Button = e.Form.Controls("Button_内转生成")
    If bt.Enabled = True
dim idx as integer = e.Form.Controls("Table_内转出库").table.findrow(e.DataRow)
        Dim tb As WinForm.Table = e.Form.Controls("Table_内转入库")
        Dim t As Table = tb.Table
        t.Rows(idx)(e.DataCol.Name) = e.DataRow(e.DataCol.Name)
    End If
End If

--  作者:huangfanzi
--  发布时间:2020/4/27 9:20:00
--  
蓝板,搞定了,还有一个问题,也请帮忙下
二个窗口的记录宽度超过窗口宽度时,下方就会有横向滚动条(这个叫法可能不对),如何也能做到联动,比如在表格1上滚动条向右一点,下方的表格2也会向右一点,因为只是在出入库方名字互换了下,上下二条记录的总长度必定是一致的,当然,我也设置了禁止调整列宽

--  作者:有点蓝
--  发布时间:2020/4/27 10:30:00
--  
参考:http://www.foxtable.com/webhelp/topics/2357.htm