Solved

Setting Focus On A Control

Posted on 2009-07-07
2
223 Views
Last Modified: 2013-12-26
I have a form with a tabcontrol.  Within the 3rd tabpage of the 1st tabcontrol is another tabcontrol.  On the 1st tabpage of the 2nd tabcontrol is a set of controls (datagridview, combobox, textbox, etc.).  When I click on the 3rd tabpage of the 1st tabcontrol the "_Enter" event for the 3rd tabpage of the 1st tabcontrol is fired and the datagridview is loaded.  Right after that I want to set the focus to the combobox that is also on that tabpage.  The combobox.focus does not seem to work.  Solution?

Private Sub tbpgTransactions_Enter(ByVal sender As Object, ByVal e As _ 
& System.EventArgs) Handles tbpgTransactions.Enter
        SqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM HM_Transactions"
        SqlDataAdapter1.Fill(HmsDataSet1.HM_Transactions)
        cbMntTrnAccountNumber.SelectedIndex = 27
        cbMntTrnAccountNumber.Focus()
    End Sub

Open in new window

0
Comment
Question by:StoneCutter3
[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
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 125 total points
ID: 24799146
Handle SelectedIndexChanged() event of the TabControl itself.

In the example below I'm using TabControl2:
    Private Sub TabControl2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TabControl2.SelectedIndexChanged
        If TabControl2.SelectedTab Is tbpgTransactions Then
            ...
            cbMntTrnAccountNumber.Focus()
        End If
    End Sub

Open in new window

0
 

Author Closing Comment

by:StoneCutter3
ID: 31600768
Nice.  Thanks alot.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month5 days, 11 hours left to enroll

626 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