Articles in this section
Category / Section

How to select a row or column when click a cell in WPF GridControl?

1 min read

WPF GridControl manages selection of cells, rows and columns using GridControl.Model.Options.AllowSelection and GridControl.Model.Options.ListBoxSelectionMode properties. Default value of AllowSelection property is Any, where GridControl allows to select range of cells, select a row when clicking row header and select a column when clicking column header. In this article, you will see how to enable row-based selection alone or column-based selection alone in GridControl.

Select a row when click any cell

WPF GridControl allows to select a row by clicking row header. You can change this setting to select a row when clicking any cell in a row by setting AllowSelection property as Row. You can also control selection mode (whether user can select single or multiple rows) by setting GridControl.Model.Options.ListBoxSelectionMode property.

Refer the below code for your reference.

C#

//To select a row while clicking the row header cell
grid.Model.Options.AllowSelection = Syncfusion.Windows.Controls.Grid.GridSelectionFlags.Row;
grid.Model.Options.ListBoxSelectionMode = Syncfusion.Windows.Controls.Grid.GridSelectionMode.MultiExtended;

 

Select a column while clicking the row header cell

Select a column when click any column header cell

The GridControl supports to select the entire column when clicking column header cell by setting AllowSelection property as Column.

Refer the below code for your reference.

C#

//To select a row or column while clicking the column header cell
grid.Model.Options.AllowSelection = Syncfusion.Windows.Controls.Grid.GridSelectionFlags.Column;

 Select a column while clicking the column header cell

Sample: View sample in GitHub


Conclusion

I hope you enjoyed learning about how to select a row or column when click a cell in WPF GridControl.

You can refer to our WPF Grid feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied