Solved

Access CheckBox controls

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

758 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

19 Experts available now in Live!

Get 1:1 Help Now