-
Jul 23rd, 2014, 06:37 AM
#1
[RESOLVED] ComboBox Behavior - error/bug
Create a combobox and add the following to the Items collection
Ab
Ac
Ad
El
En
Set the following properties
DropDownStyle = DropDownList
AutoCompleteSource - ListItems
AutoCompleteMode = Suggest
Then copy and paste the combobox
Then add the following code
Code:
Private Sub ComboBox1_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles ComboBox1.SelectionChangeCommitted
Debug.WriteLine(ComboBox1.SelectedIndex)
Debug.WriteLine(ComboBox1.Text)
ComboBox2.Select()
End Sub
Private Sub ComboBox2_Enter(sender As Object, e As EventArgs) Handles ComboBox2.Enter
Debug.WriteLine(ComboBox1.SelectedIndex)
Debug.WriteLine(ComboBox1.Text)
End Sub
Run it.
Type ab then enter, then shift tab, then ab, then enter. If you are running Windows 7 the combobox1 says Ac, if you are running Windows 8.1 it says Ab. In all cases the debug shows the correct values(0 and Ab).
-
Jul 23rd, 2014, 07:17 AM
#2
Re: ComboBox Behavior - error/bug
It appears to be cycling through the list... if you keep going it'll select Ac then Ad then back around to Ab... it also does this if you just press "a" each time in the combo box. So that may have something to do with it.
If you change it to SuggestAppend... when you shift-tab back into ComboBox1, and just press "a" ... you'll see that it selects "Ac" I suspect it has to do with how it's processing the keystrokes.
-tg
-
Jul 23rd, 2014, 07:34 AM
#3
Re: ComboBox Behavior - error/bug
Why would you set auto-complete properties if the DropDownStyle is DropDownList?
-
Jul 23rd, 2014, 07:57 AM
#4
Re: ComboBox Behavior - error/bug
Originally Posted by jmcilhinney
Why would you set auto-complete properties if the DropDownStyle is DropDownList?
The combobox is to allow the user to select a pair of letters and when they press enter it uses those values to load the second combobox with items from a DB that start with the letter pair. When I deployed this app that was developed on Win 8.1 to a Win 7 machine I found this anomaly. If the autocomplete is set to none then the first letter causes the event to fire.
Originally Posted by techgnome
It appears to be cycling through the list... if you keep going it'll select Ac then Ad then back around to Ab... it also does this if you just press "a" each time in the combo box. So that may have something to do with it.
If you change it to SuggestAppend... when you shift-tab back into ComboBox1, and just press "a" ... you'll see that it selects "Ac" I suspect it has to do with how it's processing the keystrokes.
-tg
Yes that is what it does. On Win 8.1 I don't see this behavior.
Did you notice the debug?
Last edited by dbasnett; Jul 23rd, 2014 at 08:45 AM.
-
Jul 23rd, 2014, 09:16 AM
#5
Re: ComboBox Behavior - error/bug
The problem only occurs if I .Select the other combobox. If you comment out ComboBox2.Select() and do this the problem doesn't happen.
type ab
press enter
press tab
press shift tab
type ab
press enter
press tab
press shift tab
-
Jul 24th, 2014, 05:25 AM
#6
Re: ComboBox Behavior - error/bug
I have several confirmations of how this behaves on the two platforms, but no resolutions.
-
Jul 24th, 2014, 05:50 AM
#7
Re: ComboBox Behavior - error/bug
Here is what this is about.
I am re-writing an application, in VB 2012, that manages / edits / prints an index of statutes. This is an index like you might find in the back of a book but it has 2500 major entries, such as Elections, Taxation, Schools, etc. There are over 190,000 entries that fit under the major entries. When printed it takes four volumes.
To aid the users the application takes the 2500 major entries and determines which pairs of letters are present based on the starting two letters of the major entries. Those letter pairs are loaded into a combobox. When the user selects a pair of letters another combobox is filled in with the major entries that start with those letters.
If this can't be fixed, or even if it can, is there a better way to help the user navigate the system?
-
Jul 24th, 2014, 06:28 AM
#8
Re: ComboBox Behavior - error/bug
I ask again, why would you be setting auto-complete properties if the DropDownStyle is DropDownList? DropDownList means that the user can only select an item and can't type text into the control. In fact, I just tried to set the AutoCompleteMode to Suggest when the DropDownStyle was DropDownList and the designer wouldn't let me. If you want to be able to use auto-complete then the user has to be able to type into the control, so the DropDownStyle has to be DropDown. Maybe you should just be using a TextBox with auto-complete on and forget about the drop-down list altogether.
-
Jul 24th, 2014, 06:36 AM
#9
Re: ComboBox Behavior - error/bug
Maybe this will help. They have to be set in a certain order. When I get to work I'll see if I can use a textbox to accomplish this.
Code:
Private Sub LoadMe(sender As Object, e As EventArgs) Handles MyBase.Load
'some letter pairs
ComboBox1.Items.AddRange(
New String() {"Ab", "Ac", "Ad", "Az", "El", "En"})
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
ComboBox1.AutoCompleteSource = AutoCompleteSource.ListItems
ComboBox1.AutoCompleteMode = AutoCompleteMode.Suggest
ComboBox2.Items.AddRange(
New String() {"Ab", "Ac", "Ad", "Az", "El", "En"})
ComboBox2.DropDownStyle = ComboBoxStyle.DropDownList
ComboBox2.AutoCompleteSource = AutoCompleteSource.ListItems
ComboBox2.AutoCompleteMode = AutoCompleteMode.Suggest
ActiveControl = ComboBox1
End Sub
Private Sub ComboBox1_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles ComboBox1.SelectionChangeCommitted
Debug.WriteLine("CB1Committed Index: [{0}] Text: [{1}]",
ComboBox1.SelectedIndex,
ComboBox1.Text)
ComboBox2.Select()
End Sub
Private Sub ComboBox2_Enter(sender As Object, e As EventArgs) Handles ComboBox2.Enter
Debug.WriteLine("Enter Index: [{0}] Text: [{1}]",
ComboBox1.SelectedIndex,
ComboBox1.Text)
End Sub
-
Jul 24th, 2014, 10:27 AM
#10
Re: ComboBox Behavior - error/bug
I tried the textbox approach, and the interface is not good. I didn't mention this before, and maybe I should have. If the mouse is used to make selections in the combobox it displays properly. There are 177 letter pairs in the combobox in the real system.
-
Jul 24th, 2014, 05:52 PM
#11
Re: ComboBox Behavior - error/bug
This behavior is a known bug as it turns out.
http://support.microsoft.com/kb/2868238/en-us
-
Jul 24th, 2014, 05:57 PM
#12
Re: ComboBox Behavior - error/bug
This behavior is a known bug as it turns out.
http://support.microsoft.com/kb/2868238/en-us
-
Jul 25th, 2014, 04:31 AM
#13
Re: ComboBox Behavior - error/bug
I did find a workaround.
Code:
Private Sub ComboBox1_SelectionChangeCommitted(sender As Object, e As EventArgs) Handles ComboBox1.SelectionChangeCommitted
Debug.WriteLine("CB1Committed Index: [{0}] Text: [{1}]",
ComboBox1.SelectedIndex,
ComboBox1.Text)
Dim foo As Integer = ComboBox1.SelectedIndex '<<<<<fix
ComboBox2.Select()
ComboBox1.SelectedIndex = foo '<<<<fix
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|