Vinod
Vinod

Reputation: 357

Merge Header and Cells in DataGridView Windows Forms C#

I have a requirement to display data in the following format. I am trying to find a way to merge cells or provide colspan for the cells to achieve the functionality

DataGridView final view

Found couple of articles which provides some good idea on how to achieve it. I have atleast 10 rows and 24 columns per row so performance is also a factor

https://www.codeproject.com/Articles/34037/DataGridVewTextBoxCell-with-Span-Behaviour

http://forums.codeguru.com/showthread.php?415930-DataGridView-Merging-Cells

Let me know is there any other way to implement it or should I go with WPF grid in windows forms. Any thoughts on how to implement it?

Thanks for your time

Upvotes: 0

Views: 2748

Answers (1)

DotNet Developer
DotNet Developer

Reputation: 3018

Standard DataGridView control, for example, does not support rich formatting (like Excel sheet). Only minimum - most required ones. All those solutions proposed in those posts given by you are trying to handle paint event and do some tricky painting, nothing more.

On the other hand, you should consider other alternatives too. If your data will be displayed for reading only then I recommend you to generate html document and display it with WebBrowser control. Html supports much more formatting, including merging cells.

Upvotes: 1

Related Questions