Bending the DataGridView...

Hi,

I'd like to extend the DataGridView a little bit to basically look like this:
http://kingvest.de/dgv.png

However, I'm stuck at one point:
How can I do the month aggregation as shown? Pretty important is the visual aspect of it. So it should be centered and not on the left hand side like the DataGrid does to show several tables.
I think what's probably best is to do a custom aggregation in one table rather than actually using multiple tables. So I could give one of the Month rows a specific style and use an owner drawn button for the expanding.
Please let me know if that is the way to go or if there is any better solution.

Thanks,

Tom

[765 byte] By [TomFrey] at [2007-12-16]
# 1
nobody got an idea?
TomFrey at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
The DataGridView doesn't support natively rendering children rows inline, as does the DataGrid. You might examine the DataGrid to see if it will serve your needs, but the navigation UI is different and I don't know how tweakable it is. Also, consider 3rd party grids. Some should be available at http://www.windowsforms.net.

Customizing the DGV to do this would not be a small effort, I think. You would have to create your own column type to display the +/- graphic, handle clicks on it, dynamically resize the row height, expand the editing panel (perhaps) to cover all columns, embed a grid with the child data, etc.

Perhaps someone else has a better idea...

durstin at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
what do you think of my idea to just use a row with an owner drawn button in one of the columns and hide a specific "group" of rows when the button is not clicked?
TomFrey at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4

It sounds like it's worth investigating.

Depending on your needs, you'll need to create your own editing control subclassed from Button, and change the EventArgs out to pass in the rowIndex (and probably columnIndex too while you're at it) to the Click event handler (or add your own new event), so you have the information you need to choose which rows to hide.

To use your new editing control, you'll have to create your own cell and column classes as well.

durstin at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 5

I also have to implement similar functionality. Although I haven’t started yet I was going to use the Beta 1 sample that reproduced the Outlook 2003 look-and-feel. Presumably, this sample would have the expand/collapse row feature. My only concern is the sample may have used a ListView rather and a DataGridView. Any further suggestions would be greatly appreciated.

TomT at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 6

Looking at this further, you can simulate handling a DGVButton click by handilng the DGV.CellContentClick event. This way you don't have to go through the trouble of subclassing the DGVButtonColumn and DGVButtonCell classes to expose a button Click event. In any event, you wouldn't implement an editing control, because buttons don't have an edit mode.

durstin at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...