以文本方式查看主题

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

--  作者:江南小城
--  发布时间:2016/9/8 11:42:00
--  [求助]同步
老师好,一个窗口的控件(文本框、下拉链框)要和主窗口Table的副本表同步。谢谢老师。
--  作者:有点蓝
--  发布时间:2016/9/8 14:21:00
--  
1、绑定


If e.Table.Current Is Nothing orelse forms("窗口1").opened = false Then \'如果Current为Nothing
    Return \'则返回
End
 If
 forms("窗口1").controls("textbox1").text = e.Table.Current("第一列")

--  作者:江南小城
--  发布时间:2016/9/9 11:41:00
--  
Dim t As Table = Tables("链接")
Dim cur As Row
cur = t.Current
For Each c As Col In t.Cols
    For Each ctl As WinForm.Control In e.Form.Controls
        If ctl.Name.Contains(c.Name) Then
            If c.IsBoolean Then
                cur(c.Name) = e.Form.Controls(ctl.Name).Checked
            Else
                cur(c.Name) = e.Form.Controls(ctl.Name).Value
            End If
        End If
    Next

Next
t.DataTable.Save



老师好,我在窗口新增了日期控件(DateTimePicker)通过保存按钮一起赋值给"链接"表的单元格。

--  作者:有点蓝
--  发布时间:2016/9/9 12:36:00
--  
代码么有问题,提示什么错误
--  作者:江南小城
--  发布时间:2016/9/13 13:34:00
--  
以下是引用江南小城在2016/9/9 11:41:00的发言:
Dim t As Table = Tables("链接")
Dim cur As Row
cur = t.Current
For Each c As Col In t.Cols
    For Each ctl As WinForm.Control In e.Form.Controls
        If ctl.Name.Contains(c.Name) Then
            If c.IsBoolean Then
                cur(c.Name) = e.Form.Controls(ctl.Name).Checked
            Else
                cur(c.Name) = e.Form.Controls(ctl.Name).Value
            End If
        End If
    Next

Next
t.DataTable.Save



老师好,我要对上面代码进行修改,判断链接表是否通过窗口按钮新增的行如果是窗口文本框的数据可以赋值给链接表新增的行否则提示你没有新增行同时新增一行


--  作者:有点蓝
--  发布时间:2016/9/13 14:39:00
--  
http://www.foxtable.com/webhelp/scr/0428.htm

if cur.DataRow.RowState <> DataRowState.Added then
    cur = Tables("链接").addnew()
end if

--  作者:江南小城
--  发布时间:2016/9/13 17:01:00
--  
老师好,我是要正确赋值给上次新增的行
--  作者:有点蓝
--  发布时间:2016/9/13 17:02:00
--  
Dim t As Table = Tables("链接")
Dim cur As Row
cur = t.Current
if cur.DataRow.RowState <> DataRowState.Added then
    cur = Tables("链接").addnew()
end if
For Each c As Col In t.Cols
    For Each ctl As WinForm.Control In e.Form.Controls
        If ctl.Name.Contains(c.Name) Then
            If c.IsBoolean Then
                cur(c.Name) = e.Form.Controls(ctl.Name).Checked
            Else
                cur(c.Name) = e.Form.Controls(ctl.Name).Value
            End If
        End If
    Next

Next
t.DataTable.Save

--  作者:江南小城
--  发布时间:2016/9/13 17:35:00
--  
老师,有一个问题假如我要编辑和修改怎么办,有一点熊掌与鱼的味道。
--  作者:有点蓝
--  发布时间:2016/9/13 17:45:00
--  
默认不是就可以编辑和修改吗