TableSearchRow - check if any results found

4 posts, 1 answers
  1. Martin
    Martin avatar
    35 posts
    Member since:
    Jun 2014

    Posted 10 Sep 2015 Link to this post

    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

  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    1404 posts

    Posted 11 Sep 2015 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Martin
    Martin avatar
    35 posts
    Member since:
    Jun 2014

    Posted 11 Sep 2015 in reply to Dimitar Link to this post

    That is brilliant, works a charm.

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

  5. Martin
    Martin avatar
    35 posts
    Member since:
    Jun 2014

    Posted 13 Oct 2015 in reply to Dimitar Link to this post

    Great stuff.

    Sorry for the late reply but this works perfectly!

    Thanks for your help!

Back to Top