Beruflich Dokumente
Kultur Dokumente
Smart questions
Smart answers
Smart people
Join
Directory
Search
Go Find A Forum Go
Tell A Friend
Whitepapers
Jobs
Home > Forums > Programmers > Languages > Visual Basic(Microsoft) -VB.NET Forum
johnisotank (TechnicalUser) 17
Sep
08
5:02
Hi,
I am trying to tick them all in one go but it keeps reporting the error:
I have another identical form with the same code and it works perfect so I don't understand whats wrong here..
CODE
thanks
John
mstrmage1768 (Programmer) 17
Sep
08
6:46
The problem is that you are looping through ALL the controls inside the GroupBox...and that includes what must be some Labels in the GroupBox. The
Labels cannot be cast as a CheckBox.
In this case, you need to loop through all the controls as generic controls, check to see if the control is a checkbox, cast it as a checkbox and finally check
it...
CODE
=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And
Hobbs)
www.tek-tips.com/viewthread.cfm?qid=1501031 1/2
5/21/13 Visual Basic(Microsoft) -VB.NET - Check all checkboxes in GroupBox
rjoubert (Programmer) 17
Sep
08
6:52
I noticed you have 10 labels and 10 checkboxes. Are those labels strictly for the checkboxes? If so, the checkboxes have their own TEXT property that
you can use to "label" them, so you don't need the separate label controls.
johnisotank (TechnicalUser) 17
Sep
08
7:00
Thanks Robert thats working now.
I do actually have a similar form with the same layout of groupbox and it ticks all the boxes with no problem, even with labels in there.
Thanks again
John
mstrmage1768 (Programmer) 17
Sep
08
7:08
Glad to help..... Did you see rjoubert's comment above???? That might be the difference.
=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And
Hobbs)
johnisotank (TechnicalUser) 17
Sep
08
10:36
Hi rjoubert/Robert,
Yes, that explains it. I thought my other form had labels when in fact they just had TEXT assigned to the checkbox. This is why it wasn't erroring out -
because there were no labels!
John
www.tek-tips.com/viewthread.cfm?qid=1501031 2/2