Solved

Combo boxes in Tab control becoming selected when switching tabs

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

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

Suggested Solutions

Title # Comments Views Activity
VBA to copy paste columns form one file to other 20 86
Adding to a VBA? 6 63
Help me. 3 48
Zip Folders Using Chilkat Routines 1 12
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

867 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

23 Experts available now in Live!

Get 1:1 Help Now