Version

FindString(String,Int32) Method

FindString method
Syntax
'Declaration
 
Public Overloads Overrides Function FindString( _
   ByVal s As String, _
   ByVal startIndex As Integer _
) As Integer
public override int FindString( 
   string s,
   int startIndex
)

Parameters

s
The string to search for
startIndex
The index of the first item to to be included in the search

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
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;
	}

}
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