I was wondering if there is interest in a custom combobox with more auto complete options?
Here is a list of features I’d like to implement.
Drop in replacement for existing combo box. Retaining compatibility of all methods, properties, and events. (AutoComplete would be removed.)
Specify as many columns as you wish.
Bind text to specified column
AutoComplete could search bound column or all columns
AutoComplete could be ‘starts with’ or ‘match any’ (contains)
Handle large amounts of data efficiently
Option to require selection
Drop down list would be able to protrude beyond the edge of the parent window.
Settings would allow you to set column width, list width, listrows, and column headings (on/off).
AutoFill option (only available if AutoComplete is set to BoundColumn & StartsWith)
Any more ideas before I get started?
I’ve done enough of testing to know that I can achieve all of the above 6 items.
Regarding number 6:
In tests I was able to load 1 million records 5 column wide, from a local SQLite file in .75 seconds.
Search and update autocomplete drop down list instantly even with 1 million search results being returned.
With 1 million rows and 5 columns the control will use 80-100mb of RAM. In comparison, a list box with the same amount of data uses about 650mb of RAM.
#9 listrows property should do that. I should also note that if the control is to close to the bottom edge of the screen the list will show above the control.
Well the combo box is ‘more broke’ on windows and I really need something that works. So I decided while I’m at it I might as well do it right. Unfortunately ALL my paying customers use Windows.
In the standard listbox removing a row changes the listindex but does not fire the change event even if the listindex is removed changing the text of the listbox.
In my ComboBox subclass I was thinking about firing the Change event when ever an insert or a remove causes the listindex ot the text to change.
The control should be a drop in replacement for the standard ComboBox, except for datafield, and datacontrol which are not supported.
In addition to the standard events, methods and properties I added the following:
events
Event InvalidSelection(Text as String) 'If MatchRequired then this event fires when the text entered does not exist in the list.
Event ListOpen() As Boolean 'Fires when the dropdown list is shown. Return true to prevent the list from displaying.
Event ListClose() 'Fires when the list closes
Methods
BeginTransaction 'Call before adding multiple rows to speed up insertion by 25%
Cell(Row, Column) As String 'get the value from the specified cell
Cell(Row, Column, assigns Value as String) 'sets the value of a cell
CloseDropDown 'call to close the dropdown list
CommitTransaction 'Call when finished adding multiple rows.
DropDown 'shows the dropdown list
Properties
AutoDropdown 'sets whether the drop down list is autmatically shown when typing.
AutoFill 'Choose whether the the text for matching items autofills
ColumnCount 'set or get the number of columns
ColumnWidths 'sets or gets the columnwidths of the dropdown list
DropDownVisible 'checks if the dropdown list is shown. Setting value shows/hides list.
ListRows 'The number of rows to be shown in the dropdown list
ListWidth 'The wwidth of the dropdown list
MatchRequired 'If true the text is cleared and the InvalidSelection is called when the text doesn't exist in the list.
SearchType 'Set the type of search to perform
TextColumn 'Set the column that is linked to the Text property.
1 column - 17850 items. (ListBox2 is the result when setting scrollbarvirtical to false while adding items.)
32 bit 64 bit
ComboBoxPro 0.633 0.566
ComboBox 1.666 1.466
ListBox 5.850 5.300
ListBox2 0.116 0.100
4 coulmns - 17850 items.
32 bit 64 bit
ComboBoxPro 1.050 0.833
ComboBox 1.666 1.466
ListBox 5.166 3.883
ListBox2 0.300 0.333
The list works well with 1 million items. However searching starts getting sluggish especially in ‘SearchAny’ mode.
In SearchAny mode a full text search is done on all the columns in the ComboBox. As many words can be searched as needed and the first three words can be in any order. With one million items in a 4 column list full search of three words takes about 3 seconds.
This is also very useful for customer lookup, when there are thousands of customers. In the example shown above items can be found by typing in the item code, searching the item description, or by scanning in a UPC.
My next goal is to create a listbox subclass that can set the columntype to ComboBoxPro.
Here are a few things that I’m especially pleased with, and would like to highlight.
Search feature. Flexibility, and speed.
DropDown list can protrude beyond the edge of the parent window.
Clicking on the DropDown list doesn’t ‘steel’ the focus from the parent window.
Ability to handle large amounts of data quickly and efficiently. Add 1 million rows X 4 columns in about 60 seconds. Total app memory usage goes to approx. 150Mb.
I would not store 1 millions rows in a listbox.
I would let them stay in a database (eventually in memory)
then the search result can be displayed in a listbox, it will contain much less rows
you can force the user to type 2-3 chars before displaying a result.
speed can greatly improve that way.
[quote=336782:@Jean-Yves Pochez]I would not store 1 millions rows in a listbox.
I would let them stay in a database (eventually in memory)
then the search result can be displayed in a listbox, it will contain much less rows
[/quote]
The only thing ever displayed in the listbox are the search results. The list contents are stored in an in memory SQLite database.
[quote=336782:@Jean-Yves Pochez]you can force the user to type 2-3 chars before displaying a result.
speed can greatly improve that way.[/quote]
That is an interesting thought. Currently I overcome the speed issue by showing large results in increments of 100. This makes the search appear to be instant, even when dealing with 100K records.