Solved

Setting Focus On A Control

Posted on 2009-07-07
2
202 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
2 Comments
 
LVL 85

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

705 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