Solved

Combo boxes in Tab control becoming selected when switching tabs

Posted on 2004-10-06
2
232 Views
Last Modified: 2011-09-20
I know the title of the question doesn't make much sense.  I'll try to explain further.

I have an app with multiple forms containing tab controls.  The tab controls have combo boxes on them.  Any time I run the app and move between tabs on any of the forms, all of the combo boxes on the tabs become selected.  

This one is driving me mad.  Does anyone know how to make them stop?  It is only the combo boxes.  I also have text boxes on the tabs, but they are unaffected by this apparent phenomenon.

Any help is greatly appreciated.

Regards,
Sekans
0
Comment
Question by:Sekans
2 Comments
 
LVL 8

Accepted Solution

by:
bramsquad earned 125 total points
ID: 12241606
i had this same problem when i would refresh a datagrid

im not sure what causes it, or why it happens, but i just changed the selection index everytime

use this code in your program
   
    Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
        Me.ComboBox1.SelectionLength = 0
    End Sub

~b
0
 
LVL 1

Author Comment

by:Sekans
ID: 12242622
bramsquad,

I don't believe this is a good option for me.  I have numerous forms with tab controls.  Each tab control has numerous combo boxes.  I would have to customize the code snippet for each combo box.

I found another solution.  I pasted the following code into each tab control's click event.

Dim ctrl As Control
For Each ctrl In Me.Controls
     If Left(ctrl.Name, 3) = "cbo" Then
        ctrl.SelLength = 0
    End If
Next ctrl

The "cbo" is simply the naming convention prefix I use for combo boxes.  I was hesitant to do this as I thought it could slow the screen repaint, but it hasn't affected it at all.

However, you provided a working solution so the points are yours.

Thanks for the timely response.

Sekans
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
change vba from autofit to 13.5 width? 4 29
Put text in a picture ASP.NET C# 2 57
Visual Studio 2005 text editor 10 39
RUNRMTCMD from AS/400 12 47
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…
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…
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 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…

803 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