How Do I Hide wpf datagrid row selector

WpfWpfdatagrid

Wpf Problem Overview


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?

Wpf Solutions


Solution 1 - Wpf

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

HeadersVisibility="Column"

Solution 2 - Wpf

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.

Solution 3 - Wpf

To remove the Row header(Gray field) in Datagrid in WPF

<DataGrid x:Name="TrkDataGrid" HeadersVisibility="Column">
</DataGrid>

To remove or hide the Column Header in DataGrid WPF

<DataGrid x:Name="TrkDataGrid" HeadersVisibility="Row">
</DataGrid>

To remove or hide both Column and Row Header in DataGrid WPF

<DataGrid x:Name="TrkDataGrid" HeadersVisibility="None">
</DataGrid>

Solution 4 - Wpf

Had the same problem.

Looks like the RowHeaderWidth is not supported in XAML BUT you can specify in the code behind right after the bind and it takes out that crappy selector column.

grdName.RowHeaderWidth = 0

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTim AlmondView Question on Stackoverflow
Solution 1 - WpfGeorge MavritsakisView Answer on Stackoverflow
Solution 2 - WpfslugsterView Answer on Stackoverflow
Solution 3 - WpfMaghalakshmi SaravanaView Answer on Stackoverflow
Solution 4 - WpfFrank KotulakView Answer on Stackoverflow