Hello,
How I can add a search string in a combox?
I create a project there are a form Add Category I attached the screen sort. Category Item show in a combobox(unmcmb).
It is connected with access database. Dropdown style is-- "simple". Now when I select item (using arrow key from keyboard OR click on the item)
the press enter the item come and show on the combobox(I do it is for edit category name) then I update. But now I test it So, Item list is 10-12 nos, But when category(item) is more then 100 then I lost my more time to find the Item. So, I want to when I type in combobox selection come on the perticular item text.

My project screen sort

I want like this : for example

https://ibb.co/bzgXAv

What I have tried:

unmcmb.AutoCompleteMode = AutoCompleteMode.SuggestAppend
     unmcmb.AutoCompleteSource = AutoCompleteSource.ListItems
     unmcmb.DropDownStyle = ComboBoxStyle.DropDownList

Dani AI

Generated

Short answer: make the ComboBox editable and feed its autocomplete from the actual category names (especially when the control is data-bound). The most common cause of the behavior described by is a non-editable style on the ComboBox (DropDownList blocks typing) or relying on the built-in list source when the control is bound to a DataSource. An editable style plus a custom AutoComplete collection or a small filter-on-type routine will give the instant-search behavior shown in the screenshots.

Example: build an AutoComplete collection from the database (VB.NET, WinForms):

' build AutoComplete list from a DataTable named categoriesTable
Dim acs As New AutoCompleteStringCollection()
For Each r As DataRow In categoriesTable.Rows
    acs.Add(r("CategoryName").ToString())
Next
comboCategories.AutoCompleteCustomSource = acs

After that, configure the control to allow typing and use the custom source (set in Designer or code). For "contains" matching rather than prefix matching, filter the full list on text-change and rebind the ComboBox; for large datasets, implement incremental server-side lookups instead of loading everything at once. A small TextChanged handler can update the DataSource with matches and reopen the drop-down so suggestions appear immediately.

This addresses 's clarification (autocomplete is the goal) and supplements the external thread referenced by with a concise, data-bound pattern. If the control lives in ASP.NET (WebForms/MVC) rather than WinForms, client-side widgets (jQuery UI, typeahead, or a toolkit ComboBox) should be used instead of WinForms properties.

Recommended Answers

All 3 Replies

I think what you are trying to say is that you want to Auto Complete when you are typing? Am I right? Please try to simplify what you are saying as it is not clear.

yes sir, you are right

Possibly you're look for a solution like the one on this threat Click Here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.