开发者

Grouping DataGridview in c# Winforms

Hi I have the following data in datagridview in c# winforms:


Column A | Column B | Column C | Group

 Register 1  |       10,00     |       15,00 | Group 1
 Register 2  |    开发者_Go百科   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 | Column B | Column C

Group 1

Register 1 | 10,00 | 15,00

Register 2 | 10,00 | 15,00

Group 1

Register 3 | 10,00 | 15,00

Register 4 | 10,00 | 15,00

I dont want to use multiple datagridviews


The built-in WinForms DGV does not support grouping. 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

Alternately there are countless third-party DGV controls for sale. Infragistics has an excellent one that I can recommend which does provide grouping: http://www.infragistics.com/dotnet/netadvantage/winforms/wingrid.aspx#Overview


These steps may possibly help:

Set AutoGenerateColumns to false. Create an additional TextBoxColumn which will display the Grouped column heading. Generate the other columns. Use appropriate queries to bind to the grouped data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜