当AutoGenerateColumns = True时,有没有办法在DataGrid中隐藏特定的列? [英] Is there a way to hide a specific column in a DataGrid when AutoGenerateColumns=True?
本文介绍了当AutoGenerateColumns = True时,有没有办法在DataGrid中隐藏特定的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
在您的datagrid中,订阅 AutoGeneratingColumn
事件,事件
,如果列名称是ID,则设置 args
( DataGridAutoGeneratingColumnEventArgs
)的列名称为$ code>取消 Cancel = true
。应该做的伎俩。
I have a WPF 4.0 DataGrid that is bound to a DataTable using AutoGenerateColumns=True. The columns are dynamic, however I know there is always going to be a column named ID and I would like to hide this column. Is there a way I can do this?
解决方案
in your datagrid, subscribe for the AutoGeneratingColumn
event, the event args
(DataGridAutoGeneratingColumnEventArgs
) has the column name and a "Cancel
", if the column name is ID then set Cancel = true
. should do the trick.
这篇关于当AutoGenerateColumns = True时,有没有办法在DataGrid中隐藏特定的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文