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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

96691 Sep 29,2010 06:56 AM UTC Oct 13,2010 06:25 PM UTC WPF 3
loading
Tags: GridControl
Ramana
Asked On September 29, 2010 06:56 AM UTC

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.


Kamalakannan A [Syncfusion]
Replied On 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.



Ramana
Replied On 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.


Kamalakannan A [Syncfusion]
Replied On 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.



CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;