nahumba
asked on
Problem getting CheckState of checkboxes from inside a class - vb.net
Dear Experts,
I have a class which contains a very simple routine which needs to get the status of some check boxes on my Form (i.e, checked, unchecked).
However,
I am unable to get the status - I will always get "FALSE" returned - even if the check boxes are checked.
(Please see my attached code)
If I'll put this routine inside my Form1, it will work - how can I solve this?
Thanks!
I have a class which contains a very simple routine which needs to get the status of some check boxes on my Form (i.e, checked, unchecked).
However,
I am unable to get the status - I will always get "FALSE" returned - even if the check boxes are checked.
(Please see my attached code)
If I'll put this routine inside my Form1, it will work - how can I solve this?
Thanks!
Dim ctrl As Control
Dim checkbox As CheckBox
For Each ctrl In form1.GroupBox2.Controls
if typeof(ctrl) Is Checkbox then
checkbox = ctrl
MsgBox(checkbox.Checked)
end if
Next
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What happens if you refer to the checkbox by it's ID instead of looping? Do you get the expected result? Also, if you move this little method to the very top of your page_load, what happens? I'm just trying to diagnose problems to find out what's going on... not really saying these are permanent solutions.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Guys,
1) I did try to put this method on the very top of my page_load - works fine... the problem is that I must call this method from inside a class in a different module.
2) This is not an ASP.net application.
Thanks again!
1) I did try to put this method on the very top of my page_load - works fine... the problem is that I must call this method from inside a class in a different module.
2) This is not an ASP.net application.
Thanks again!
ASKER
Hi guys,
I'm sorry - that was MY mistake... Apparently I was calling this method from a different thread - this is obviously the reason for my problem!
Thanks again!
I'm sorry - that was MY mistake... Apparently I was calling this method from a different thread - this is obviously the reason for my problem!
Thanks again!
ASKER
No, Im not reloading them on the page_load event...
thanks