This is a migrated thread and some comments may be shown as answers.

TableSearchRow - check if any results found

3 Answers 133 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Martin
Top achievements
Rank 1
Martin asked on 10 Sep 2015, 03:59 PM

Hi,

I have a function to search a grid programatically which works fine. This uses the MasterView.TableSearchRowSearch(searchvalue);

grd.MasterView.TableSearchRow.AutomaticallySelectFirstResult = true;

grd.MasterView.TableSearchRow.HighlightResults = true;
grd.MasterView.TableSearchRow.InitialSearchResultsTreshold = 1;
grd.MasterView.TableSearchRow.Search(searchvalue);

I would like to make it slicker by showing a messagebox if no matches are found once the search is completed and also to return the index of the 1st found match. Is here a way to get search result back or determine if the search is completed?

Thanks.

 

Here is a

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 11 Sep 2015, 02:24 PM
Hello Martin,

Thank you for writing.

You can use the SearchProgressChanged event and display a message if the string is not found. For example:
private void radButton1_Click(object sender, EventArgs e)
{
    radGridView1.MasterView.TableSearchRow.SearchProgressChanged += searchRow_SearchProgressChanged;
 
    radGridView1.MasterView.TableSearchRow.AutomaticallySelectFirstResult = true;
    radGridView1.MasterView.TableSearchRow.HighlightResults = true;
    radGridView1.MasterView.TableSearchRow.InitialSearchResultsTreshold = 1;
    radGridView1.MasterView.TableSearchRow.Search("test");
}
 
void searchRow_SearchProgressChanged(object sender, SearchProgressChangedEventArgs e)
{
    GridViewSearchRowInfo searchRow = sender as GridViewSearchRowInfo;
 
    if (e.SearchFinished && searchRow.CurrentSearchResultsCount == 0)
    {
        Console.WriteLine("No Items fond");
    }   
}

Please let me know if there is something else I can help you with. 

Regards,
Dimitar
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Martin
Top achievements
Rank 1
answered on 11 Sep 2015, 03:41 PM

That is brilliant, works a charm.

Nice and simple adding an event handler too - many thanks!

0
Martin
Top achievements
Rank 1
answered on 13 Oct 2015, 10:12 AM

Great stuff.

Sorry for the late reply but this works perfectly!

Thanks for your help!

Tags
GridView
Asked by
Martin
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Martin
Top achievements
Rank 1
Share this question
or