Searching Data
Spread WinRT Documentation > Developer's Guide > Managing Data > Searching Data

You can search for a string in the control and specify options such as the case, exact match, wild cards, cell range to search, and the order to search in. You can search cell text, cell tags, or formulas.

You can use the Search method to find items in code.

Using Code

This example uses the Search method.

CS
Copy Code
private void Grid_Loaded_1(object sender, RoutedEventArgs e)
        {
            gcSpreadSheet1.Sheets[0].Cells[5, 4].Text = "test";        
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            int colfound;
            int rowfound;
            int sheetfound;
            string foundstring;
            colfound = 0;
            rowfound = 0;
            sheetfound = 0;
            gcSpreadSheet1.SheetCount = 2;
            //gcSpreadSheet1.Search(0, "test", out rowfound, out colfound);
            //gcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, out rowfound, out colfound);
            //gcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, out rowfound, out colfound);
            //gcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, out rowfound, out colfound);
            //gcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, GrapeCity.Xaml.SpreadSheet.Data.SheetArea.Cells, out rowfound, out colfound);
            //gcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, GrapeCity.Xaml.SpreadSheet.Data.SheetArea.Cells, 0, 0, out rowfound, out colfound);
            //gcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, GrapeCity.Xaml.SpreadSheet.Data.SheetArea.Cells, 0, 0, 7, 7, out rowfound, out colfound);
            //gcSpreadSheet1.Search(0, 1, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, GrapeCity.Xaml.SpreadSheet.Data.SheetArea.Cells, 0, 0, 7, 7, out sheetfound, out rowfound, out colfound);
            gcSpreadSheet1.Search(0, 0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, GrapeCity.Xaml.SpreadSheet.Data.SheetArea.Cells, 0, 0, 7, 7, out sheetfound, out rowfound, out colfound, out foundstring);
            listBox1.Items.Add(colfound.ToString());          
        }
VB
Copy Code
Private Sub MainPage_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
        gcSpreadSheet1.Sheets(0).Cells(5, 4).Text = "test"
    End Sub
    Private Sub Button_Click_1(sender As Object, e As RoutedEventArgs)
        Dim colfound As Integer
        Dim rowfound As Integer
        Dim sheetfound As Integer
        Dim foundstring As String
        colfound = 0
        rowfound = 0
        sheetfound = 0
        foundstring = ""
        gcSpreadSheet1.SheetCount = 2
        'GcSpreadSheet1.Search(0, "test", rowfound, colfound)
        'GcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, rowfound, colfound)
        'GcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, rowfound, colfound)
        'GcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, rowfound, colfound)
        'GcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, GrapeCity.Xaml.SpreadSheet.Data.SheetArea.Cells, rowfound, colfound)
        'GcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, GrapeCity.Xaml.SpreadSheet.Data.SheetArea.Cells, 0, 0, rowfound, colfound)
        'GcSpreadSheet1.Search(0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, GrapeCity.Xaml.SpreadSheet.Data.SheetArea.Cells, 0, 0, 7, 7, rowfound, colfound)
        'GcSpreadSheet1.Search(0, 1, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, GrapeCity.Xaml.SpreadSheet.Data.SheetArea.Cells, 0, 0, 7, 7, sheetfound, rowfound, colfound)
        gcSpreadSheet1.Search(0, 0, "test", GrapeCity.Xaml.SpreadSheet.Data.SearchFlags.ExactMatch, GrapeCity.Xaml.SpreadSheet.Data.SearchOrder.ZOrder, GrapeCity.Xaml.SpreadSheet.Data.SearchFoundFlags.CellText, GrapeCity.Xaml.SpreadSheet.Data.SheetArea.Cells, 0, 0, 7, 7, sheetfound, rowfound, colfound, foundstring)
        ListBox1.Items.Add(colfound.ToString())
    End Sub
See Also