Solved

Combo boxes in Tab control becoming selected when switching tabs

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…
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…

832 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