简体   繁体   English

在C#Winforms中对DataGridview进行分组

[英]Grouping DataGridview in c# Winforms

Hi I have the following data in datagridview in c# winforms: 嗨,我在c#winforms的datagridview中有以下数据:


Column A | A栏| Column B | B栏| Column C | C栏| Group

 Register 1  |       10,00     |       15,00 | Group 1
 Register 2  |       10,00     |       15,00 | Group 1
 Register 3  |       10,00     |       15,00 | Group 2
 Register 4  |       10,00     |       15,00 | Group 2

I want to get this in the following form: 我想以以下形式获取:


Column A | A栏| Column B | B栏| Column C C栏

Group 1 第一组
Register 1 | 注册1 | 10,00 | 10,00 | 15,00 15,00
Register 2 | 注册2 | 10,00 | 10,00 | 15,00 15,00
Group 1 第一组
Register 3 | 注册3 | 10,00 | 10,00 | 15,00 15,00
Register 4 | 注册4 | 10,00 | 10,00 | 15,00 15,00

I dont want to use multiple datagridviews 我不想使用多个datagridviews

The built-in WinForms DGV does not support grouping. 内置的WinForms DGV不支持分组。 Here is an article where someone has added this functionality themselves (note that I have not used this myself and so am not making a recommendation): http://blogs.vbcity.com/hotdog/archive/2008/12/19/9226.aspx 这是一篇文章,其中有人亲自添加了此功能(请注意,我自己并没有使用此功能,因此未提出建议): http : //blogs.vbcity.com/hotdog/archive/2008/12/19/9226 .aspx

Alternately there are countless third-party DGV controls for sale. 或者,有数不清的第三方DGV控件可供出售。 Infragistics has an excellent one that I can recommend which does provide grouping: http://www.infragistics.com/dotnet/netadvantage/winforms/wingrid.aspx#Overview 我可以推荐Infragistics出色的一种,它确实提供了分组: http : //www.infragistics.com/dotnet/netadvantage/winforms/wingrid.aspx#Overview

These steps may possibly help: 这些步骤可能会有所帮助:

Set AutoGenerateColumns to false. 将AutoGenerateColumns设置为false。 Create an additional TextBoxColumn which will display the Grouped column heading. 创建一个附加的TextBoxColumn,将显示“分组的”列标题。 Generate the other columns. 生成其他列。 Use appropriate queries to bind to the grouped data. 使用适当的查询绑定到分组的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM