By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,822 Members | 1,053 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,822 IT Pros & Developers. It's quick & easy.

problem with checkbox

P: n/a
I have a problem.
I'd like, when i click on a button , to check all the checkbox that i
have in the form.

I have tried with :

For Each Myobj As Control In Me.Controls
If TypeOf Myobj Is CheckBox Then
If Myobj.checked Then
...
...
...
End If
End If
Next

but i have an error on myobj.checked :
'checked' in not a member of 'system.windows.forms.controls'

Thank you
Luca

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies

P: n/a
"luca.gere" <lu*******@gmail.com> wrote in message news:11**********************@g44g2000cwa.googlegr oups.com...
I have a problem.
I'd like, when i click on a button , to check all the checkbox that i
have in the form.

I have tried with :

For Each Myobj As Control In Me.Controls
If TypeOf Myobj Is CheckBox Then
Change the following line: If Myobj.checked Then
to:

If CType(Myobj, CheckBox).checked Then
...
...
...
End If
End If
Next

but i have an error on myobj.checked :
'checked' in not a member of 'system.windows.forms.controls'

Thank you
Luca


I hope that helps.

--
Al Reid
Nov 21 '05 #2

P: n/a
the line i use it to control re state of the check box and i'd like to
chenge it.
for example

If Myobj.checked Then
Myobj.checked=false
else
Myobj.checked=true
endif

Nov 21 '05 #3

P: n/a


--
Al Reid

"It ain't what you don't know that gets you into trouble. It's what you know
for sure that just ain't so." --- Mark Twain

"luca.gere" <lu*******@gmail.com> wrote in message news:11**********************@f14g2000cwb.googlegr oups.com...
the line i use it to control re state of the check box and i'd like to
chenge it.
for example

If Myobj.checked Then
Myobj.checked=false
else
Myobj.checked=true
endif


Perhaps the following instead:

If TypeOf Myobj Is CheckBox Then
Dim MyCheck As Checkbox = CType(Myobj, CheckBox)
If MyCheck.checked Then
MyCheck.checked=false
Else
MyCheck.checked=true
End If
End If

Or maybe:

If TypeOf Myobj Is CheckBox Then
CType(Myobj, CheckBox).Checked = Not CType(Myobj, CheckBox).Checked
End If

I hope that helps.

--
Al Reid
Nov 21 '05 #4

P: n/a
perfect

thank you :-)

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.