Version 24.2 (latest)

FindString(String) Method

FindString method
Syntax
public virtual int FindString( 
   string s
)

Parameters

s
The string to search for

Return Value

The index of the first item that contains a match for the specified string
Example
This sample finds the string specified, selects it, and highlights it within the list.

Private Sub SelectString(ByVal str As String)

' Attempt to find passed in string.
     Dim index As Integer = Me.UltraComboEditor1.FindString(str)

     If index <> -1 Then
		' String has been found, highlight it. First restore appearance on non
		' highlighted items

         Dim i As Integer
         For i = 0 To Me.UltraComboEditor1.Items.Count - 1
             If i <> index Then
                 Me.UltraComboEditor1.Items(i).Appearance.FontData.Reset()
                 Me.UltraComboEditor1.Items(i).Appearance.ResetBackColor()
             End If
         Next i

		' Highlight the found item in the list
         Dim item As Infragistics.Win.ValueListItem = Me.UltraComboEditor1.Items(index)

         item.Appearance.BackColor = Color.Yellow
         item.Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True

		' Set the selected item
         Me.UltraComboEditor1.SelectedItem = item
     End If
	
 End Sub
'Declaration
 
Public Overloads Overridable Function FindString( _
   ByVal s As String _
) As Integer
 
private void SelectString(string str)
{

	// Attempt to find passed in string.
	int index = this.ultraComboEditor1.FindString(str);

	if (index != -1)
	{

		// String has been found, highlight it. First restore appearance on non
		// highlighted items
		for(int i = 0; i < this.ultraComboEditor1.Items.Count ; i++)
		{
			if (i != index)
			{
				this.ultraComboEditor1.Items[i].Appearance.FontData.Reset();
				this.ultraComboEditor1.Items[i].Appearance.ResetBackColor();
			}
		}

		// Highlight the found item in the list
		Infragistics.Win.ValueListItem item = this.ultraComboEditor1.Items[index] as Infragistics.Win.ValueListItem;

		item.Appearance.BackColor = Color.Yellow;
		item.Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True ;

		// Set the selected item
		this.ultraComboEditor1.SelectedItem = item;
	}

}
'Declaration
 
Public Overloads Overridable Function FindString( _
   ByVal s As String _
) As Integer
 
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also