How Do I Hide wpf datagrid row selector

有些话、适合烂在心里 提交于 2019-11-28 21:43:40

问题


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?


回答1:


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.




回答2:


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

HeadersVisibility="Column"



回答3:


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



来源:https://stackoverflow.com/questions/2865505/how-do-i-hide-wpf-datagrid-row-selector

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!