BaseListBoxControl.FindStringExact(String) Method

Finds the first item in the list box control which matches the specified string exactly.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v20.2.dll


public int FindStringExact(
    string s
Public Function FindStringExact(
    s As String
) As Integer


Name Type Description
s String

A string value specifying the search text.


Type Description

An integer value representing the zero-based index of the first item found. -1 if no item is found.


This method searches for the first item with text that matches the search text exactly. Note: the search is not case-sensitive.

If you want to search for a partial text, use the BaseListBoxControl.FindString method.


The following sample code declares a DeleteSameItems method. This method searches for the item specified by the s parameter. If found, it searches for items same as that specified and removes them from the list box items collection. As a result, only one item specified by the parameter is displayed.

Note: this method works if no data source is bound to the list box control. Otherwise, method execution will not take effect.

The image below demonstrates the ListBoxControl control's look & feel before and after sample code execution.

BaseListBox - FindStringExact

private void DeleteSameItems(ListBoxControl listBox, string s){
   // the index of the first found item within the ListBoxControl
   int index = listBox.FindStringExact(s);
   if (index == -1 || index == listBox.ItemCount - 1) return;
   while (index <= listBox.ItemCount - 1){
      if (listBox.FindStringExact(s, index) != -1){
         index = listBox.FindStringExact(s, index);
// ...
DeleteSameItems(listBoxControl1, "Chicago");
See Also