Solved

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

Posted on 2007-11-15
6
576 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

21 Experts available now in Live!

Get 1:1 Help Now