FindAllInstancesOfText()

Finds all occurences of a particular string within the control

Syntax
c#
public int[] FindAllInstancesOfText(string text)
{ 
}

Parameters
Parameter Name Type Description
text System.String The string to search for


Return Value
Returns an array of integer that define the zero based index where each occurence of the string was found.

Remarks
The FindAllInstancesOfText method will search within the text of the control for all occurences of the specified string. To find just the first occurence of the specified string you can use the FindText() method.

Examples

c#
// Find all occurences of the string within the textbox control from the start of the text.
public void FindString(SGBTextBox textBox, string searchValue)
{
    if(control != null)
    {
          int[] results = textBox.FindAllInstancesOfText(searchValue);
          foreach(int i in results)
         {
               Console.Write(string.Format("Instance of {0} found at {1}", searchValue, i));
         }
    } 
}

vb.net
' Find all occurences of the string within the textbox control from the start of the text. 
Public Sub FindString(ByVal textBox As SGBTextBox, ByVal searchValue As String) 
    If control IsNot Nothing Then 
        Dim results As Integer() = textBox.FindAllInstancesOfText(searchValue) 
        For Each i As Integer In results 
            Console.Write(String.Format("Instance of {0} found at {1}", searchValue, i)) 
        Next 
    End If 
End Sub 

Known Issues
none

Last edited Mar 30, 2010 at 12:07 PM by scottgblood, version 2

Comments

No comments yet.