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.
Unfortunately, activation email could not send to your email. Please try again.

How to select the entire column in SfDataGrid ?

 

In SfDataGrid you can select the entire column by using SfDataGrid.SelectCells method. The cell selection is enabled by setting the SfDataGrid.SelectionUnit as Cell or Any and the SfDataGrid.SelectionMode as Extended or Multiple for selecting the entire column.

You can select the range of cells by passing the starting record of selection, column and ending record of selection and column as parameter to SfDataGrid.SelectCells method. In this case, pass starting and ending record in View with the column to be selected as in the following code example.

 

By handling the VisualContainer.MouseLeftButtonUp event, you can click on the Header of the SfDataGrid to select a particular column by using the following code example.

 

In the above code example, VisualContainer.PointToCellRowColumnIndex is used to get the RowColumnIndex of selected cell.

SfDataGrid.GetRecordAtRowIndex is a helper present in the Syncfusion.UI.Xaml.Grid.Helpers. It is used to get the record corresponding to the RowIndex.

Sample link:

WPF: http://www.syncfusion.com/downloads/support/directtrac/149035/ze/WPF-96643012933260182

Article ID: Published Date: Last Revised Date: Platform: Control:
5072 05/27/2015 01/13/2016 WPF SfDataGrid
Did you find this information helpful?
Comments
nobert jurkiewicz Jan 20, 2017
I needed to add 

 this.sfdatagrid.ClearSelection(true)

before

this.sfdatagrid.SelectCells(firstrowdata, column, lastrowdata, column);

to make sure only the clicked column is highlighted.
Reply
Add Comment
You must log in to leave a comment

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.