WPF DataGrid 默认列类型

发布于 2024-08-28 18:34:55 字数 393 浏览 3 评论 0原文

我正在使用 DataGrid 在 DataTable 中显示 2 种可能类型的 DataRow。一种类型的列 Parent = NULL,另一种类型的 Parent 设置为同一 DataTable 中的另一个 DataRow。数据表中的列列表总是不同的,因此明确描述每一列是不可能的。

我想在 Parent = DataRow 行的每个单元格中显示 UserControl,并在 Parent = NULL 行的默认文本/复选框中显示。我的第一个策略是尝试将所有自动生成的列的默认列类型设置为 DataGridTemplateColumn,无论数据类型如何,以便我可以使用样式在需要时使用我的 UserControl 或 CheckBox 或 TextBox。我该怎么做?

但更重要的是,还有比这更好的策略吗?

干杯, 戴夫

I'm using a DataGrid to display 2 possible types of DataRow in a DataTable. One type has the column Parent = NULL and the other has Parent set to another DataRow in the same DataTable. The list of column in the DataTable is always different, so explicitly describing each column is not possible.

I want to display a UserControl in every cell of the Parent = DataRow rows, and default Text / Check boxes for the Parent = NULL rows. My first strategy is to try and set the default Column type for all automatically generated columns to be a DataGridTemplateColumn, regardless of datatype, so that I can use styles to then use either my UserControl or CheckBox or TextBox where required. How can I do this?

More importantly, though, is there a better strategy than this?

Cheers,
Dave

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文