Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Do I Hide wpf datagrid row selector

I'm using the WPF DataGrid control to show some details and a select button, and I don't need the gray selector column down the left-hand side. It's also ruining the beauty of my design.

Is there a way to remove it, or how can I style it to match if not?

like image 393
Tim Almond Avatar asked May 19 '10 12:05

Tim Almond


People also ask

What is the difference between grid and DataGrid in WPF?

A Grid is a control for laying out other controls on the form (or page). A DataGrid is a control for displaying tabular data as read from a database for example.

Can user delete rows WPF?

By default, the user can delete rows by selecting one or more rows and pressing the DELETE key.

How do I add a DataGrid toolbox?

Right Click the Toolbox. Select "Choose Items...". In the WPF Components Tab, in the Filter Textbox type DataGrid. From there you can add it to the Toolbox.


2 Answers

Instead of setting the Width you can completely hide the row headers by setting on the DataGrid

HeadersVisibility="Column" 
like image 72
George Mavritsakis Avatar answered Sep 18 '22 00:09

George Mavritsakis


Use the RowHeaderWidth property:

<my:DataGrid RowHeaderWidth="0" AutoGenerateColumns="False" Name="dataGrid1" /> 

Note that you can also specify a style or template for it also, should you decide you really do like it and want to keep it because you can do something cool with it.

like image 45
slugster Avatar answered Sep 17 '22 00:09

slugster