johnisotank
Technical User
Hi,
I have a groupbox with 10 labels and 10 checkboxes.
I am trying to tick them all in one go but it keeps reporting the error:
Unable to cast object of type 'System.Windows.Forms.Label' to type 'System.Windows.Forms.CheckBox'.
I have another identical form with the same code and it works perfect so I don't understand whats wrong here..
could anyone advise pls?
thanks
John
I have a groupbox with 10 labels and 10 checkboxes.
I am trying to tick them all in one go but it keeps reporting the error:
Unable to cast object of type 'System.Windows.Forms.Label' to type 'System.Windows.Forms.CheckBox'.
I have another identical form with the same code and it works perfect so I don't understand whats wrong here..
Code:
For Each ctrl As CheckBox In MyGroupBox.Controls
ctrl.Checked = True
Next
could anyone advise pls?
thanks
John