Solved

Problem getting CheckState of checkboxes from inside a class - vb.net

Posted on 2007-11-15
6
575 Views
Last Modified: 2013-11-26
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!
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

Open in new window

0
Comment
Question by:nahumba
  • 3
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
Chumad earned 400 total points
Comment Utility
Do you re-load the checkbox list in the page_load? If you do, that is going to reset any checked values. You need to check for page.IsPostBack and only load your checkbox list if it evaluates to FALSE...

if not page.isPostBack then
   'load list boxes'
end if
0
 

Author Comment

by:nahumba
Comment Utility
Hi,
No, Im not reloading them on the page_load event...


thanks
0
 
LVL 8

Expert Comment

by:Chumad
Comment Utility
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.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 100 total points
Comment Utility
>>No, Im not reloading them on the page_load event...
Is this an ASP.net question?
0
 

Author Comment

by:nahumba
Comment Utility
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!
0
 

Author Comment

by:nahumba
Comment Utility
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!

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Copy a file to a share on a Domain 3 54
Replacing HTML tags in Textarea/Textbox 5 22
Convert string to date 3 39
Create XML 5 30
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now