Combo provides in-built functionality to perform search on the entire combo box list. This topic discusses how to enable search in the Combo control.
To perform search operation, you can use FindString method of the C1Combo class. The method has parameters that let you set the target string, starting index of the row, and much more. Besides this, you can use FindStringExact method of the C1Combo class to search for the exact match.
The following code snippet demonstrates how to search for a value using FindString method.
C# |
Copy Code
|
---|---|
var found = -1; //search in every column for (int col = 0; col < c1Combo1.Columns.Count; col++) { //search for the string found = c1Combo1.Find("search"); //if found set the selected index if (found != -1) { c1Combo1.SelectedIndex = found; return; } } |
The Combo control facilitates end-users to enable search mismatch in the list by using Mismatch event of the C1Combo class. The Mismatch event is triggered whenever the user enters a value in the combo box that is not found in the combo list. Please note that the Mismatch event is only fired when the LimitToList property is set to true.
The following GIF shows how the Mismatch event is fired in the Combo control. In this example, the user entered "9" which is not found in the combo box.
The following code demonstrates how to enable search mismatch in the Combo control by subscribing to the Mismatch event.
C# |
Copy Code
|
---|---|
private void C1Combo1_Mismatch(object sender, C1.Win.List.MismatchEventArgs e) { //if NewEntry entered by the user is not empty or white space if (!string.IsNullOrEmpty(e.NewEntry) || !string.IsNullOrWhiteSpace(e.NewEntry)) { //show the message box when Match Not found MessageBox.Show("Match Not found"); } } |