我有一个表单,我正在运行该表单中的所有控件。我的代码没问题,可以获取所有控件及其所有属性。
因此,例如,我有一个 TabControl,每个 tabPage 中有 2 个 TabPages 和 2 个文本框。
问题是对于未选中的tabPage,文本框的可见属性为False,尽管我已将其设置为True。
我试图用 Control.Select 和 Control.Focus 解决这个问题,但 Visible 仍然是 False:
Private Sub createXML(ByVal cnt As Control, ByVal elem As XElement)
Try
cnt.Select()
cnt.Focus()
Select Case cnt.Controls.Count
Case Is = 0
'Code here to write XElement to an XDocument
'Check Controls properties
Case Is > 0
For Each childCnt As Control In cnt.Controls
childCnt.Select()
childCnt.Focus()
Dim childElem As New XElement(childCnt.GetType.ToString)
Select Case childCnt.Controls.Count
Case Is = 0
'Code here to write XElement to an XDocument
'Check Controls properties
Case Is > 0
createXML(childCnt, childElem)
End Select
Next
End Select
有任何想法吗?请注意,我不知道每次必须运行哪些控件