我正在尝试禁用.Load表单中的所有控件,除了少数几个。因为我禁用了很多控件并且只启用了一些控件,所以我没有使用类似于TypeOf Control Is ComboBox然后在我的循环中。我将逐一启用它们。
我的问题是,当我在循环之后立即启用它们时,只有menustrip和按钮才能工作。其他(组合框和文本框)将保持锁定状态。
以下是我的代码中的这一部分:
Private Sub AddForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim addformcontrol As Control
For Each addformcontrol In Me.Controls
addformcontrol.Enabled = False
Next
someComboBox.Enabled = True
someTextBox.Enabled = True
MenuStrip1.Enabled = True
CleanAllButton.Enabled = True
End Sub
感谢。
答案 0 :(得分:0)
如果这些控件位于容器(例如组框)中,并且该控件已禁用,则启用子控件将无法完成此任务。