Solved

Access CheckBox controls

Posted on 2013-01-30
5
237 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
[X]
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
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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 …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

617 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