R
Rickard
I am trying to create a custom DataGridView control that displays data
from a DataSet, but with the additional functionality that it shows
"headlines" in the data. Example (pardon my lack of ASCII art skills):
---------------------------------
| Name | Age | Oranges |
---------------------------------
| - Old people |
---------------------------------
| John | 65 | 3 |
| Bill | 75 | 1 |
| Sarah | 77 | 5 |
| Homer | 93 | 4 |
---------------------------------
| - Young people |
---------------------------------
| Emily | 3 | 6 |
| John Jr.| 4 | 13 |
| S | 7 | 54 |
| George | 11 | 1 |
My first thought was to add DataRows for each headline and override the
Paint method to draw whatever I want, but it seems there is no way to
add unbound DataRows in a bound DataGridView, is it?
So is there a simple way of doing this. Working in unbound mode is not
really an option since I need to have a lot of existing code working
with this inherited DataGridView control, and neither is finding a
closed-source third-party control since I need compatibility with
DataGridView + there is a lot of other customizations going into this
inherited control.
I guess what I'm looking for is some way of hooking in between the data
binding and the actual generation of DataRow objects. I tried overriding
the DataRowCollection object, but there seems to be no way of changing
bindings on a row level.
Another approach would be not using DataRows at all, but instead somehow
configure the layout of the grid and do all header painting in the Paint
method of the grid itself, but alas GetRowDisplayRectangle is not
virtual
I really don't know where to look for this change. I have seen one
similar control on CodeProject:
http://www.codeproject.com/cs/miscctrl/OutlookGrid.asp
but unfortunately this control seems to be unbound and requires a lot of
changes to the interfacing.
Any help is appeciated, as I'm quite stuck as it is and not even Google
will help me
/ Richard
from a DataSet, but with the additional functionality that it shows
"headlines" in the data. Example (pardon my lack of ASCII art skills):
---------------------------------
| Name | Age | Oranges |
---------------------------------
| - Old people |
---------------------------------
| John | 65 | 3 |
| Bill | 75 | 1 |
| Sarah | 77 | 5 |
| Homer | 93 | 4 |
---------------------------------
| - Young people |
---------------------------------
| Emily | 3 | 6 |
| John Jr.| 4 | 13 |
| S | 7 | 54 |
| George | 11 | 1 |
My first thought was to add DataRows for each headline and override the
Paint method to draw whatever I want, but it seems there is no way to
add unbound DataRows in a bound DataGridView, is it?
So is there a simple way of doing this. Working in unbound mode is not
really an option since I need to have a lot of existing code working
with this inherited DataGridView control, and neither is finding a
closed-source third-party control since I need compatibility with
DataGridView + there is a lot of other customizations going into this
inherited control.
I guess what I'm looking for is some way of hooking in between the data
binding and the actual generation of DataRow objects. I tried overriding
the DataRowCollection object, but there seems to be no way of changing
bindings on a row level.
Another approach would be not using DataRows at all, but instead somehow
configure the layout of the grid and do all header painting in the Paint
method of the grid itself, but alas GetRowDisplayRectangle is not
virtual
I really don't know where to look for this change. I have seen one
similar control on CodeProject:
http://www.codeproject.com/cs/miscctrl/OutlookGrid.asp
but unfortunately this control seems to be unbound and requires a lot of
changes to the interfacing.
Any help is appeciated, as I'm quite stuck as it is and not even Google
will help me
/ Richard