AutoSuggestion in Combobox - c++

I created a Combobox with CreateWindowEx. Everything goes well. But I would like to make a final feature: AutoSuggestion. The Combobox is used to do search text in a document, hence at some point, it have items that are the strings a user searched. The AutoSuggestion should be: drop down the list of items, find those items that begin with the string that a user typed in the edit control, but do not select one of them, do not display all other items, and finally do not change select item when keydown or keyup occurs, only highlight the item and select only when a user press Enter. Do you have any idea how to accomplish this task?

It sounds like you want Autocomplete functionality.

Related

Winforms controlling controls

I couldn't think of a coherent search term for my problem so please forgive me if this has been asked before.
I have 24 combo boxes sitting on a panel control, displayed in 4 rows of 6.
After the user defines the value for each combo and hits the "go" button, I add all combo boxes to list so I can use the values in another section of my program.
The problem is that the order the comboboxes are added to the list is messed up, compared to their visual layout on the panel, and I would like to define the order. Currently, it adds the 9th combobox to the list first then the 20th, 2nd, 16th etc etc.
I tried TabIndex but that didnt work.
Before I manually rename and relabel all of the boxes, any other suggestions will be gratefully received.
The controls of your form exist in Controls collection of the container controls, for example when you add a Panel and a Button to a Form and two ComboBox to the Panel, then:
Form.Controls contains button1 and panel1
Panel.Controls contains comboBox1 and comboBox2
Controls are added to the Controls collection, with the same order that you add them to designer. Open designer.cs, look at the end of InitializeComponent to see the order.
You can also see/change the order using Document Outline window.
That said, now it should be obvious that panel1.Controls.OfType<ComboBox>() returns combo boxes with the same order that you see in Document Outline (or based on their z-index, and it doesn't have anything to do with their x/y placements).
You may want to order them based on TabIndex, or any other property that you like:
panel1.Controls.OfType<ComboBox>().OrderBy(x=>x.TabIndex)
Note
In general, if you are going to use those values for a search, instead of relying on the order of values, a much better idea is creating a SearchModel class which has a few properties, the set those properties to the selected value of the corresponding combo box (manually or using databinding) then pass the search model to the other classes.

Change label of QComboxBox without using lineEdit

Currently I want to implement a widget to allow user to enable/disbale all provided options of a QSet. So i took a combobox and added selectable items. So far so good, but how I can change text displayed in combobox? Currently all my items have just ItemIsUserCheckable and ItemIsEnabled as enabled flags (ItemIsSelectable is not enabled), so text of ComboBox is always text of first item. Instead I want as text "Flag1, Flag 3, Flag6" if there multiple flags and user enabled Flag 1, 3 and 6. But setCurrentText and setEditText requiring setEditable(true) or an custom lineEdit. But using an lineEdit is changing appearance. So is there another way?
I had a similar problem a while back, I ended up 'solving' it by adding an extra item to my model that was first in the list and always set as the current item. I then updated it's text to say 'Select items...' or 'X item(s) selected' as appropriate.

qt combobox readable but editable

I have at QComboBox some items (added by program - it is a lot added items (about 1000))
So i make combobox editable -> then it is simple to find a correct item. (For example if i want to find item called "My Example" i write in combobox "MY" and i get items which starts from "MY" )
But when i write somethink other than it is in combobox, combobox add this item.
I dont want it, i want only to:
Can select only ITEMS added by Program
Block adding custom items
When i write something like "MY" but dont select item "My Example" because there is "My Example","My Example2"
And press push button to accept my choice - then how to check that i choice item from items added by Program not written and not finished by User?
Set these QComboBox properties to the following:
1. Set setEditable to true.
2. Set insertPolicy to NoInsert.
3. Set currentIndex to -1 to make it empty at start.
Then process currentIndexChanged signal which will be sent only when a certain item from the list is chosen.

Tkinter - Changing the list in Option Menu

Is there a way to manipulate the List displayed by the OptionMenu in respect to what the user has currently selected?
For example, let's say I have a list - ["A","B","C"].
If the user currently selected A then if he clicks the optionmenu with A currently selected, what he will see in the list is not the original list but only B and C.
If he switches his answer from, let's say, A to B, then now, he will only see A and C in the OptionMenu.
And the same will follow if he chose B or C.
Thanks!
The OptionMenu widget is a button that shows a dropdown menu when pressed. You might do better to use a ttk.Combobox instead as that is a more modern UI element and you can very simply configure the values configuration item.
You can configure the attached menu at runtime. You access the menu using optionmenu['menu'] and you can then query items on the menu optionmenu['menu'].entrycget(0, 'label') or use entryconfigure to modify the items. Or you can delete items optionmenu['menu'].delete(index) and add new items. See the menu documentation for hints on manipulating the menu entries.

Dealing with huge select lists

I often use select lists with my projects but when it comes to a huge select list, I couldn't find a solution. I need a easy, plug and play solution for solution will be used in a few places.
When you have a select box or text box to be filled from a model data, I want to show user a text box, right side of text box, there should be a button to choice the value. Upon clicking that button, popup or a modal will be opened and I filter all the records and find my value, upon clicking value, modal or popup closes and I get choosen value to form control.
İmagine you have a text box to choose your customer, and among 2500 customer,
PS:don't suggest autocomplete, don't want to accomplish it.
Why don't you look at something like Chozen plugin http://harvesthq.github.io/chosen/. It allows you to easily search large select lists