ComboBox Autocomplete


Author
Message
Doug Birtell
Doug Birtell
StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)StrataFrame Beginner (33 reputation)
Group: Forum Members
Posts: 33, Visits: 64
I have multiple comboboxes on a winform that are bound to business objects.  It seems that no matter how I set the Autocomplete, or DropdownStyle, or BindingProperty, I get these results.

If I type very quickly, then the list narrows to the correct item,

If I type too slow, then the list always goes to the item that starts with the letter I just typed.

i.e.  If we were to use state abbreviations as an example...

If I type M, then the combobox will select ME. (the first of the M's)  If I was wanting the abbreviation MD, and I then slowly type a 'D' after the 'M', then the combobox goes to DE, not MD as I would expect.  HOWEVER ! ! ! IF I TYPE MD REALLY QUICKLY, then it works. 

Is there some type of event handler that I need to code to change the behavior to what I would expect?

Thanks!

Doug

Replies
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I'm not exactly which event you'd use (parent form loading maybe), but here is how you'd figure out if the combo has only one choice, then select that choice:



'-- This determines the count of items that would be in the

'combo if there are NO items from the db. Note that the

'initialization to zero is for clarity...integers are

'initialized to zero automatically.

Dim zeroDbItemCount As Integer = 0

If Me.cboSample.TopMostItem IsNot Nothing Then

zeroDbItemCount = 1

End If



'-- If the combo has only one db item, select this item.

'Note that we need exactly one more item than our zero count.

If Me.cboSample.Items.Count = zeroDbItemCount + 1 Then

'-- This is kind of lazy, reusing the zeroDbItemCount as the index, but

'this count will also be the actual index of the first db

'item. I.e. if there is no top most item, the first db item has

'an index of zero. If there is a top most item, the first db item

'has an index of 1.

Me.cboSample.SelectedItem = Me.cboSample.Items(zeroDbItemCount)

End If




I just typed this in, so I may have made some typing mistakes, but this should get you going.
Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Greg,



Thanks a lot, that is exactly what I was looking for. I tested it and it works just great!, very simple coding. w00t

Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Glad that was it! BigGrin
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Doug Birtell - 17 Years Ago
Dustin Taylor - 17 Years Ago
Doug Birtell - 17 Years Ago
Edhy Rijo - 17 Years Ago
                     Maybe in those cases you have use the Enter key? Just a guess...
Greg McGuffey - 17 Years Ago
                         Hi Greg, Sorry, but basically you can not move focus with the...
Edhy Rijo - 17 Years Ago
                             We'll take a look a this, but it sounds kindof fishy. This should not...
Trent L. Taylor - 17 Years Ago
                                 Trent, Dustin, No mean to rush you, but when you have a chance, see if...
Edhy Rijo - 17 Years Ago
                                     Got it and reproduced it. I will add this to the list. Thanks.
Trent L. Taylor - 17 Years Ago
                                         Hi Trent, Have you find a fix for this one?
Edhy Rijo - 16 Years Ago
                                             Not yet. I have it on my "cut sheet" but have not worked through this...
Trent L. Taylor - 16 Years Ago
                                                 Thanks for the info.
Edhy Rijo - 16 Years Ago
                                                 [quote][b]Trent L. Taylor (01/20/2009)[/b][hr]Not yet. I have it on my...
Edhy Rijo - 16 Years Ago
                                                     Sorry...this had a low priority since it was only documented in one...
Trent L. Taylor - 16 Years Ago
                                                         Thanks.
Edhy Rijo - 16 Years Ago
                                                             Trent,

FYI, setting the TabOrderController.EnterAdvances =...
Edhy Rijo - 16 Years Ago
                                                                 Forgot to mention that the problem is also happening with SF Textboxes...
Edhy Rijo - 16 Years Ago
                                                                     Edhy, I just set up a test and it worked. So you may need to produce...
Trent L. Taylor - 16 Years Ago
                                                                         Hi Trent,
Here is the sample posted by Dustin before, I modified...
Edhy Rijo - 16 Years Ago
                                                                             Fixed. It will be in the next update.
Trent L. Taylor - 16 Years Ago
                                                                                 Thanks Trent.

On a similar subject, I have a combo that in...
Edhy Rijo - 16 Years Ago
                                                                                     Well, first you would just need to bind the combo to the BO. Next, why...
Trent L. Taylor - 16 Years Ago
                                                                                         [quote][b]Trent L. Taylor (04/29/2009)[/b][hr]Well, first you would...
Edhy Rijo - 16 Years Ago
                                                                                             I'm not exactly which event you'd use (parent form loading maybe), but...
Greg McGuffey - 16 Years Ago
                                                                                                 Hi Greg,

Thanks a lot, that is exactly what I was looking...
Edhy Rijo - 16 Years Ago
                                                                                                     Glad that was it! :D
Greg McGuffey - 16 Years Ago
Dustin Taylor - 17 Years Ago
Doug Birtell - 17 Years Ago
Edhy Rijo - 17 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search