Customize Column Header of DataGrid

J

Java

Hi All,

Is it possibe to customize the Column header of DataGrid control. I need to
draw some icons based on some criteria?

Javed.
 
U

Ulrich Sprick

Hi,

in a derived columnstyle class the paint method is used to paint the cell values. So I guess you will have to look at the datagrid
columnstyles collection class, or even the datagrid tablestyle.
hth,
ulrich
 
J

Java

Hi Ulrich,

I already checked it, but it doesnt allow to access Column Header whose
index is -1.

Javed.

Ulrich Sprick said:
Hi,

in a derived columnstyle class the paint method is used to paint the cell
values. So I guess you will have to look at the datagrid
 
U

Ulrich Sprick

Hi,

I believe the headers are painted by
- the grid, or
- the tablestyle.
The tablestyle has some properties that affect header appearance, but no OnPaint method to override. But the grid has. Maybe, the
grid does the drawing, or it calls some method of the (active) tablestyle. What happens if you override the grid's OnPaint and
simply do a return? Does the header disappear?

cheers, ulrich
 
I

Iulian Ionescu

Indeed the painting of the column headers is handled by
the OnPaint event of the Grid. the grid calls paint
background and then it paints the column headers; after
that it calls each gridcolumnstyle's Paint event to draw
the cells... There is not too much you can customize
though except colors and font. You cannot change the
size. The size is defined in a Layout structure and some
items (caption and column headers height) have a fixed
size that you cannot change...
-----Original Message-----
Hi,

I believe the headers are painted by
- the grid, or
- the tablestyle.
The tablestyle has some properties that affect header
appearance, but no OnPaint method to override. But the
grid has. Maybe, the
grid does the drawing, or it calls some method of the
(active) tablestyle. What happens if you override the
grid's OnPaint and
 
U

Ulrich Sprick

Hi ,
Indeed the painting of the column headers is handled by
the OnPaint event of the Grid. the grid calls paint
background and then it paints the column headers; after
that it calls each gridcolumnstyle's Paint event to draw
the cells...

Then there 2 options to go:
- Either create a new grid control, or
- derive the existing grid and override relevant methods.

The first option is much work, I'm pretty shure. The second might turn into a nightmare: To change the grid logic is not so much
work, but you must have exact knowledge about the grid's internals. Knowledge that is not in the documentation. I can tell you a
story about creating custom datagrid columnstyles...

ulli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top