Solved

Access CheckBox controls

Posted on 2013-01-30
5
231 Views
Last Modified: 2013-01-30
Hi...Can i please have a guideline on how to access a checkBox within controls?
Form->TabControl1->TabPage2->GroupBox->CheckBox (Change the CheckState)
There is No Problem when i am trying access the CheckBox in TabPage1
But when i try in TabPage2 nothing happens..
0
Comment
  • 3
  • 2
5 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 38834824
Is tabpage2 in focus when you try? Controls on tabpages not shown yet are not created unless that tabpage gets focus.
0
 
LVL 18

Author Comment

by:John (Yiannis) Toutountzoglou
ID: 38834829
No TabPage1 is the one it has Focus...so is that the reason why? i know the theory but i imagine that because the controls are placed in the document outline in this siries it is possible to have an access
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 250 total points
ID: 38834854
Try shifting focus to tabpage2 before accessing the checkbox. Otherwise, you can put this logic in tabpagechanging event and set the controls when tabpage2 gets focused by user.
0
 
LVL 18

Author Comment

by:John (Yiannis) Toutountzoglou
ID: 38834857
Ok...I will use then the TabControl1.Selected Event and acess then the desire Control...
Thank you Nasir!
0
 
LVL 18

Author Comment

by:John (Yiannis) Toutountzoglou
ID: 38835501
Just for info ...my final code ....
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
        Try
            If DirectCast(sender, TabControl).SelectedIndex = 1 Then 'Is the Second Tabpage
                For i As Integer = 1 To 3
                    For Each ctl As Control In Me.TabPage2.Controls.Find("Page2GroupBox" & i, True)(0).Controls
                        If TypeOf ctl Is CheckBox Then
                            If Not DirectCast(ctl, CheckBox).CheckState = CheckState.Checked Then
                                DirectCast(ctl, CheckBox).CheckState = CheckState.Unchecked
                            End If
                        End If
                    Next
                Next

            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message, "ErrorOccured", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

Open in new window

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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

16 Experts available now in Live!

Get 1:1 Help Now