Solved

Access CheckBox controls

Posted on 2013-01-30
5
234 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
get row value in vb.net 4 18
"Emulate" TAB key when press Enter Key 3 49
SSRS 2016 Rendering HTML tables 3 31
Access Schema 6 26
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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