Spread Windows Forms 12.0 Product Documentation
Search(Int32,String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Int32,Int32,Int32,Int32,Int32,Int32) Method
Example 


FarPoint.Win.Spread Assembly > FarPoint.Win.Spread Namespace > FpSpread Class > Search Method : Search(Int32,String,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Boolean,Int32,Int32,Int32,Int32,Int32,Int32) Method
Sheet index on which to search
String for which to search
Whether the search considers the case of the letters in the search string
Whether the search considers only an exact match
Whether the search goes by alternate coordinates of column, row (instead of row, column)
Whether the search considers wildcard characters (*, ?) in the search string
Whether the search includes the content in the cell
Whether the search includes the content in the cell notes
Whether the search includes the content in the cell tags or their string representations
Specifies whether to search the specified block of cells only
Row Index at which to start
Column index at which to start
Row Index at which to end
Column index at which to end
Row Index at which match is found
Column index at which match is found
Searches the text in the specified range of cells in the specified sheet for the specified string with the specified criteria.
Syntax
'Declaration
 
Public Overloads Function Search( _
   ByVal sheetIndex As Integer, _
   ByVal searchString As String, _
   ByVal caseSensitive As Boolean, _
   ByVal exactMatch As Boolean, _
   ByVal alternateSearch As Boolean, _
   ByVal useWildcards As Boolean, _
   ByVal includeCellText As Boolean, _
   ByVal includeNotes As Boolean, _
   ByVal includeTags As Boolean, _
   ByVal searchAsBlockRange As Boolean, _
   ByVal startRowIndex As Integer, _
   ByVal startColumnIndex As Integer, _
   ByVal endRowIndex As Integer, _
   ByVal endColumnIndex As Integer, _
   ByRef foundRowIndex As Integer, _
   ByRef foundColumnIndex As Integer _
) As SearchFoundFlags
'Usage
 
Dim instance As FpSpread
Dim sheetIndex As Integer
Dim searchString As String
Dim caseSensitive As Boolean
Dim exactMatch As Boolean
Dim alternateSearch As Boolean
Dim useWildcards As Boolean
Dim includeCellText As Boolean
Dim includeNotes As Boolean
Dim includeTags As Boolean
Dim searchAsBlockRange As Boolean
Dim startRowIndex As Integer
Dim startColumnIndex As Integer
Dim endRowIndex As Integer
Dim endColumnIndex As Integer
Dim foundRowIndex As Integer
Dim foundColumnIndex As Integer
Dim value As SearchFoundFlags
 
value = instance.Search(sheetIndex, searchString, caseSensitive, exactMatch, alternateSearch, useWildcards, includeCellText, includeNotes, includeTags, searchAsBlockRange, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex, foundRowIndex, foundColumnIndex)

Parameters

sheetIndex
Sheet index on which to search
searchString
String for which to search
caseSensitive
Whether the search considers the case of the letters in the search string
exactMatch
Whether the search considers only an exact match
alternateSearch
Whether the search goes by alternate coordinates of column, row (instead of row, column)
useWildcards
Whether the search considers wildcard characters (*, ?) in the search string
includeCellText
Whether the search includes the content in the cell
includeNotes
Whether the search includes the content in the cell notes
includeTags
Whether the search includes the content in the cell tags or their string representations
searchAsBlockRange
Specifies whether to search the specified block of cells only
startRowIndex
Row Index at which to start
startColumnIndex
Column index at which to start
endRowIndex
Row Index at which to end
endColumnIndex
Column index at which to end
foundRowIndex
Row Index at which match is found
foundColumnIndex
Column index at which match is found

Return Value

SearchFoundFlags settings indicating in what type cell or cell item the string is found is returned.

Also, the foundRowIndex and foundColumnIndex return the row index and column index of the cell in which the string is found.

Remarks

The more recently added search methods return a SearchFoundFlag, and not simply a text string, because the search match might be found in the cell notes or the cell tags. You can search optionally any or all of the data cells, the cell notes, or the cell tags or any combination. It starts at the cell location specified (with startRowIndex and startColumnIndex) and goes to the specified end (endRowIndex and endRowIndex) until the string match is found. In addition you can limit the left-most column, right-most column, top-most row, and bottom-most row of the search by specifying a block range.

To do this, you set the searchAsBlockRange to true and then the start and end indexes serve as the defining limits of the search. For example if your start column index is 5, the search never goes to columns less than an index of 5 in any row.

If cells are searched, this search method searches all the cells that contain data that can be represented as a string by the Text property of that cell, and that includes hidden and locked cells.

This search method checks the formatted string, that is the Text in the cell, not the Value. If tags are searched, it only searches tags that are String data type.

For a hierarchy of sheets, this method only searches cells in a parent sheet. To search child sheets, you would need to perform a separate search of each child sheet.

The searchAsBlockRange will limit the search to the range as if it is a block of cells. If the search starts with row 0, column 1 and ends at row 3, column 3 then column 0 would not be searched and columns after 3 would not be searched. With searchAsBlockRange set to true, the default search will go from left to right first and then top to bottom. An alternate search would go from top to bottom and then left to right.

If searchAsBlockRange is false then the search will include all cells in the sheet after the specified cell (including cells not in the range).

Example
The first example returns the location of the specified string. The second example finds all instances of a word in a block of cells.
int x = 0;  
int y = 0; 
FarPoint.Win.Spread.SearchFoundFlags sff; 
sff = fpSpread1.Search(0, "test", false, false, false, false, true, false, false, true, 0, 1, 3, 3, ref x, ref y);
listBox1.Items.Add(sff.ToString()); 
listBox1.Items.Add(x.ToString()); 
listBox1.Items.Add(y.ToString()); 
Dim x As Integer
Dim y As Integer
Dim z As Integer
Dim sff As FarPoint.Win.Spread.SearchFoundFlags
sff = FpSpread1.Search(0, "test", False, False, False, False, True, False, False, True, 0, 1, 3, 3, x, y)
ListBox1.Items.Add(sff.ToString())
ListBox1.Items.Add(x)
ListBox1.Items.Add(y)
FpSpread1.Sheets(0).Cells(0, 0).Text = "test"
FpSpread1.Sheets(0).Cells(3, 0).Text = "test"
FpSpread1.Sheets(0).Cells(4, 0).Text = "test"
FpSpread1.Sheets(0).Cells(0, 1).Text = "test"
FpSpread1.Sheets(0).Cells(3, 1).Text = "test"
FpSpread1.Sheets(0).Cells(3, 2).Text = "test"

Dim x As Integer
Dim y As Integer
Dim i As Integer
Dim j As Integer
i = 0
j = 0

For j = 0 To 5
    i = 0
    While x <> -1 Or i > 5
        FpSpread1.Search(0, "test", False, False, False, False, True, False, False, True, i, j, 5, 5, x, y)
        ListBox1.Items.Add(x.ToString())
        ListBox1.Items.Add(y.ToString())
        i = x + 1
    End While
    x = 0
    i = x + 1
Next j
FpSpread1.Sheets(0).Cells(0, 0).Text = "test"
FpSpread1.Sheets(0).Cells(3, 0).Text = "test"
FpSpread1.Sheets(0).Cells(4, 0).Text = "test"
FpSpread1.Sheets(0).Cells(0, 1).Text = "test"
FpSpread1.Sheets(0).Cells(3, 1).Text = "test"
FpSpread1.Sheets(0).Cells(3, 2).Text = "test"

Dim x As Integer
Dim y As Integer
Dim i As Integer
Dim j As Integer
i = 0
j = 0

For j = 0 To 5
    i = 0
    While x <> -1 Or i > 5
        FpSpread1.Search(0, "test", False, False, False, False, True, False, False, True, i, j, 5, 5, x, y)
        ListBox1.Items.Add(x.ToString())
        ListBox1.Items.Add(y.ToString())
        i = x + 1
    End While
    x = 0
    i = x + 1
Next j
See Also

Reference

FpSpread Class
FpSpread Members
Overload List
SearchFoundFlags Enumeration
Customizing User Searching of Data