WPF DataGrid 默认列类型
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论