Jump to content

$CBS_SORT behaviour


Arik
 Share

Recommended Posts

Hello to all the great autoit experts.
 
I use a long script that amongst other actions it creates a gui with a combo box. I use an ini file for its entries with dozens of sections and stumbled upon a problem with the $CBS_SORT style.
I wrote a small example to show the problem and hope you have an answer for me:

#include <GUIConstants.au3>

GUICreate("My GUI combo")

GUICtrlCreateCombo("", 10, 10, 100, 20, $CBS_DROPDOWNLIST + $CBS_AUTOHSCROLL + $CBS_SORT)
GUICtrlSetData(-1, "1 Option|2 Option|3 Option|4 Option|5 Option|6 Option|7 Option|8 Option|9 Option|10 Option|11 Option|12 Option")

GUISetState()

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd 

When opening the drop box menu, the options are displayed "1 Option10 Option11 Option12 Option2 Option3 Option4 Option5 Option6 Option7 Option8 Option9 Option". Is there any way to sort the entries as "1 Option2 Option3 Option4 Option5 Option6 Option7 Option8 Option9 Option10 Option11 Option12 Option", but still keep the $CBS_SORT style?

Thanks for any help.

Edited by Arik
Link to comment
Share on other sites

Yes. You can do it but not as easily as you probably think.

You can store your values into 2D array - each value split by space and put to first and second array dimension.

Then sort array by first dimension with numeric type of comparision

Finally fill ComboBox from sorted array a put result string for each item as concatenate of first and second array dimension item.

Edited by Zedna
Link to comment
Share on other sites

Zedna, thanks for your answer, but your solution sounds too complicated for me.

I initially use the $CBS_SORT style because of another problem i encountered. I wanted that when the user types the starting characters of the entry, the dropbox will change according to what he types. In the upper example if the user types "12", the dropbox will select "12 Option". If you remove the $CBS_SORT style from the GUICtrlCreateCombo command, the entries are displayed in the exact order of the data given, but when the user types "12", the "2 Option" is selected. This applies also when the entries are letters, for example, "Adobe|Dropbox". Is there a solution, a simple one i hope, for this problem?

Link to comment
Share on other sites

You can create your own "autosearch" functionality.

Try to search this forum I'm sure I have seen such scripts here, just use some apropriate keyword for searching, maybe:

+combo +auto +search

+combo +autocomplete

+combobox +autocomplete

...

Don't forget to search "in titles only".

Edited by Zedna
Link to comment
Share on other sites

You can create your own "autosearch" functionality.

Try to search this forum I'm sure I have seen such scripts here, just use some apropriate keyword for searching, maybe:

+combo +auto +search

+combo +autocomplete

+combobox +autocomplete

...

Don't forget to search "in titles only".

Zedna, I searched according to your suggestions and all the results I've got were relevant to JScript's solution: they don't use $CBS_DROPDOWNLIST at all.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...