我有带有 tabcontrol 的表单和几个标签页,其中包含文本框和复选框中的许多设置。
当用户从该表单中按退出时,我必须检查数据是否已更改。
为此,我想在表单上的所有值的 Enter 上创建一个字符串,并将其与退出时的所有值的字符串进行比较:
Private Function getsetupstring() As String
Dim setupstring As String = ""
For Each oControl As Control In Me.Controls
If TypeOf oControl Is CheckBox Then
Dim chk As CheckBox = CType(oControl, CheckBox)
setupstring &= chk.Checked.ToString
End If
If TypeOf oControl Is TextBox Then
setupstring &= oControl.Text.Trim.ToString
End If
Next
Return setupstring
End Function
但是该代码不会遍历标签页上的控件,只有 TabControl 和表单顶部的几个按钮。
如何列出所有控件以便我可以选择值?