Solved

Setting Focus On A Control

Posted on 2009-07-07
2
206 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

863 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

21 Experts available now in Live!

Get 1:1 Help Now