我想通过代码去定义窗口的所有控件,因为有时窗口的控件很多。我的代码如下:
For Each kj As WinForm.Control In e.Form.Controls
If Typeof kj Is WinForm.TextBox Then '判断控件是否是文本框
Dim kj.name As WinForm.TextBox = kj '
End If
If Typeof kj Is WinForm.Button Then '判断控件是否是文本框
Dim kj.Name As WinForm.Button = kj '
End If
If Typeof kj Is WinForm.Label Then '判断控件是否是文本框
Dim kj.Name As WinForm.Label = kj '
End If
If Typeof kj Is WinForm.Table Then '判断控件是否是文本框
Dim kj.Name As WinForm.Table = kj '
End If
If Typeof kj Is WinForm.ComboBox Then '判断控件是否是文本框
Dim kj.Name As WinForm.ComboBox = kj '
End If
Next
这样会出错,说应为语免结束。请问各位老师,要如何实现。多谢!