Solved

Combo boxes in Tab control becoming selected when switching tabs

Posted on 2004-10-06
2
230 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 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

16 Experts available now in Live!

Get 1:1 Help Now