Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Setting Focus On A Control

Posted on 2009-07-07
2
Medium Priority
?
224 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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

670 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