我有一个简单的vb 2010表单,我希望能够设置所有按钮的启用声明。 我已经为复选框和numericUpDown控件做了类似的功能,但是对于按钮而言,这个功能似乎并不正确。设置按钮启用状态
Private Sub setButtonsState(ByVal state As Boolean)
Dim cControl As Control
For Each cControl In Me.Controls
If (TypeOf cControl Is Button) Then
cControl.Enabled = state
End If
Next cControl
End Sub
被称为像这样:setButtonsState(True)
这似乎没有任何效果的按钮可言,虽然buttonName.Enabled = True
作品OK ...... Im相当多,你想叫什么,在VB一个小白,所以任何人帮帮我? Ta
这可能是由于按钮位于组框中。然而,给出的错误“'HasControls'不是'System.Windows.Forms.Control'的成员。”... – Toby
我想他可能是.haschildren例如...如果(ctrl.HasChildren)那么。 ..*继续。 – Ccorock
试图更改为hasChildren,但然后为setButtonsState(ctrl.Controls,状态)发生未处理的invalidCast的消息 – Toby