Create Dual Headers or Group Headers in your DataGridView control
I have searched online for a solution to create dual or multiple headers for the DataGridView control and so far, they don't suit my requirements. I needed to add customizable "group headers" that spans above their "child" column headers, as well as having the flexibility to add more child or group columns.
Some examples online either:
- Adds datacolumns having same names, and then merge those columns having similar names or,
- Merging columns by predefined pairs.
Those examples are good BUT it doesn't give you the flexibility of adding more columns under specific "GROUP HEADERS".
Furthermore, all those examples exhibit this weird scrolling problem where the painted new header disappears if the default child column disappears from the horizontal scrolling view:
So I have created my own solution that:
- Addresses this "disappearing" header problem upon scrolling horizontally.
- You can freely customize the style and add as many group headers as you want.
Feel free to download and improve it.
Thanks!
Marc