BaseListBoxControl.FindStringExact(String, Int32) Method

Finds the first item which matches the specified string exactly.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v20.2.dll


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


Name Type Description
s String

A string value specifying the search text.

startIndex Int32

An integer value representing the zero-based index of the first item to be searched.


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 exactly matches the search text. The startIndex parameter specifies where the search starts. Set it to -1 to search from the beginning of the list box control. Note, the search is not case-sensitive.

If you want to search for 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