以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  控件绑定到表无法修改值  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=189777)

--  作者:lur320
--  发布时间:2023/12/25 15:46:00
--  控件绑定到表无法修改值
 窗体中的控件绑定到了一个表格的列。
有另外一个开关来确定那些控件是显示或隐藏的。想要实现每次变动开关后,隐藏的控件的值被清空。如何实现?

For Each c As WinForm.Control In e.Form.Controls
    If TypeOf c Is WinForm.DateTimePicker AndAlso c.Visible = False Then \'判断控件是否是文本框
        Dim t As WinForm.DateTimePicker = c \'使用特定类型的变量引用控件
        t.BindRow(t.BindingField) = Nothing
        这个会报错

    End If
     If TypeOf c Is WinForm.NumericComboBox AndAlso c.Visible = False Then \'判断控件是否是文本框
        Dim t As WinForm.NumericComboBox = c \'使用特定类型的变量引用控件
        t.Text = Nothing 这个不能改变值
        t.Value = Nothing 这个不能改变值

    End If
Next

--  作者:lur320
--  发布时间:2023/12/25 15:49:00
--  
 实际上,每次输入数据后,表格中已经有了数值,只是row没有保存,

所以切换开关只是把控件隐藏了。里面的值没有变化。

如何实现在窗体上切换开环,清空隐藏的控件的数值?

--  作者:有点蓝
--  发布时间:2023/12/25 15:53:00
--  
For Each c As WinForm.Control In e.Form.Controls
If TypeOf c Is WinForm.DateTimePicker AndAlso c.Visible = False Then \'判断控件是否是文本框
    c.BindTable(c.BindCol.Name) = Nothing
end if
Next 
[此贴子已经被作者于2023/12/25 15:53:16编辑过]