Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2007-11-15
6
578 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
ID: 20290536
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
ID: 20290570
Hi,
No, Im not reloading them on the page_load event...


thanks
0
 
LVL 8

Expert Comment

by:Chumad
ID: 20290610
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 55

Assisted Solution

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

Author Comment

by:nahumba
ID: 20292492
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
ID: 20294684
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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