当AutoGenerateColumns = True时,有没有办法在DataGrid中隐藏特定的列?

编程入门 行业动态 更新时间:2024-10-15 18:25:25
本文介绍了当AutoGenerateColumns = True时,有没有办法在DataGrid中隐藏特定的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个WPF 4.0 DataGrid绑定到DataTable使用AutoGenerateColumns = True。列是动态的,但是我知道总是会有一个名为ID的列,我想隐藏这个列。有没有办法我可以这样做?

解决方案

在您的datagrid中,订阅 AutoGeneratingColumn 事件,事件 args ( DataGridAutoGeneratingColumnEventArgs )的列名称为$ code>取消,如果列名称是ID,则设置 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中隐藏特定的列?

本文发布于:2023-07-09 01:20:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1082536.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:没有办法   AutoGenerateColumns   True   DataGrid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!