窗体中的控件绑定到了一个表格的列。
有另外一个开关来确定那些控件是显示或隐藏的。想要实现每次变动开关后,隐藏的控件的值被清空。如何实现?
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