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

Select all Rows based on search

1 Answer 97 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Claude
Top achievements
Rank 1
Iron
Veteran
Claude asked on 31 Dec 2020, 11:09 PM

I would like to select all rows based on the text typed in the search box or create a collection  of rows that contain the search text. 

 

For example if the user types 'cat" into the search box. is there a way to auto select those rows so the user could drag and drop.  I have the drag and drop working for selected rows, just wanted a new way  in selecting rows.   

 

1 Answer, 1 is accepted

Sort by
0
Nadya | Tech Support Engineer
Telerik team
answered on 04 Jan 2021, 03:30 PM

Hello, Claude,

In order to achieve your requirement, you should enable the multiple selections in RadGridView by setting the MultiSelect property to true. Then, you can handle the SearchProgressChanged event. From the e.Cells collection you can get the GridSearchResultCellInfos and mark the respective RowInfos as selected. Please refer to the following code snippet:

this.radGridView1.MultiSelect = true;
this.radGridView1.SelectionMode = GridViewSelectionMode.FullRowSelect;
this.radGridView1.MasterView.TableSearchRow.SearchProgressChanged += this.TableSearchRow_SearchProgressChanged;

 private void TableSearchRow_SearchProgressChanged(object sender, SearchProgressChangedEventArgs e)
 {
     GridViewSearchRowInfo searchRow = sender as GridViewSearchRowInfo;

     if (e.SearchFinished && searchRow.CurrentSearchResultsCount > 0)
     {
         foreach (GridSearchResultCellInfo cellInfo in e.Cells)
         {
             cellInfo.RowInfo.IsSelected = true;
         }
     }
 }

More information about searching functionality is available here: https://docs.telerik.com/devtools/winforms/controls/gridview/rows/search-row 

I hope this helps. Should you have any other questions please let me know.

Regards,
Nadya
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
Claude
Top achievements
Rank 1
Iron
Veteran
Answers by
Nadya | Tech Support Engineer
Telerik team
Share this question
or