Winforms control that works as ajax tag completion

I want to create a winforms application where you can assign entity tags. ofc I want the client to reuse existing tags. That's why I want to show them a list of tags as they are input (similar to intellisense in VS and the dropdown tag even here in stackoverflow;))

  • Do you have any controls that offer this feature?
  • Is it possible to reuse ComboBox for this? (here I need to omit it programmatically - how?)

I want the taglist to get input focus, but not lose the main focus, and I want it to be on top of all windows and even go out of the main form area (for example, intellisense in vs)

THX!

+3
source share
1 answer

Here I created a function for which the name of the table is passed from which automatic completion should be performed, the name of the field that should be autocompleted, and the combo box that needs to be configured.

Try using the following code:

public void AutoCompleteTextBox(string tableName, string fieldName, ComboBox combToAutoComp)
        {
            AutoCompleteStringCollection txtCollection = new AutoCompleteStringCollection();
            DataTable dtAutoComp = Dal.ExecuteDataSetBySelect("Stored_Procedure", fieldName, tableName);
            if (dtAutoComp.Rows.Count >= 0)
            {
                for (int count = 0; count < dtAutoComp.Rows.Count; count++)
                {
                    txtCollection.Add(dtAutoComp.Rows[count][fieldName].ToString());
                }
            }
            combToAutoComp.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            combToAutoComp.AutoCompleteSource = AutoCompleteSource.CustomSource;
            combToAutoComp.AutoCompleteCustomSource = txtCollection;
        }

Here Dal.ExecuteDataSetBySelectis my implementation where I create a connection, a command and a dataadapter to call a stored procedure. You can replace it with your own implementation for the same. See this link for more details.

+1
source

Source: https://habr.com/ru/post/1736271/


All Articles