We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

How to Select/UnSelect all the row in the DataGrid at once.

I'm using GridDataControl , I want to Select/UnSelect all the rows in the DataGrid. That is when the use clicks on 'Select all' button all the rows in the DataGrid should be selected, in the same for UnSelection.


3 Replies

KA Kamalakannan A Syncfusion Team October 7, 2010 01:31 PM UTC

Hi Ramana,

Thank you for using Syncfusion products.

GridDataControl allows to add or remove the entire table from the selected ranges using the code as follows.

[Code Snippet] [C#]

private void Button_Click(object sender, RoutedEventArgs e)
{
this.dataGrid.Model.SelectedRanges.Add(GridRangeInfo.Table());
this.dataGrid.Model.InvalidateCell(GridRangeInfo.Table());
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
this.dataGrid.Model.SelectedRanges.Clear();
this.dataGrid.Model.InvalidateCell(GridRangeInfo.Table());

}

Please find the attached samples for your reference.

Sample: Selection_Sample150419584.zip

Let us know if you need any more information.

Thanks
Kamal.




RA Ramana October 8, 2010 05:05 AM UTC

HI,
Thanks for your reply, when I click on SelectAll it simply selecting, but when I check the selected items of the grid like this 'dgvInwardFiles.SelectedItems' it containing zero.When I select all the Items in the Grid manually using mouse and when I click on UnSelect it is simply unselecing but when I check the selected items of the grid like this 'dgvInwardFiles.SelectedItems' it containing all grid items.

Please give me some solution.



KA Kamalakannan A Syncfusion Team October 13, 2010 06:25 PM UTC

Hi Ramana,

Thanks for your update.

The records in the grid can be added in the selected item list as follows.

[Code Snippet] [C#]

private void Button_Click(object sender, RoutedEventArgs e)
{
this.dataGrid.Model.SelectedRanges.Add(GridRangeInfo.Table());
this.dataGrid.SelectedItems[0] = this.dataGrid.Model.View.Records.ToList();
this.dataGrid.Model.InvalidateCell(GridRangeInfo.Table());
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
this.dataGrid.Model.SelectedRanges.Clear();
this.dataGrid.SelectedItems[0] = null;
this.dataGrid.Model.InvalidateCell(GridRangeInfo.Table());
}


Let us know if you need any more information.

Thanks
Kamal.



Loader.
Live Chat Icon For mobile
Up arrow icon