image in a datagrid column header

H

harry

Hello,

I would like to instead of placing text in to the header of a column in a
windows.forms.datagrid
to place an image instead. Can it be done? Googling doesn't seem to come up
with anything like this
except for creation of an image column style, which is close to what I want
but not quite close enough
(as I actually want the column to contain checkboxes).

On another similar note is it possible to have multi-line column headers,
where the header could wrap in accordance with the
width of the column so you can always read what it says (more or less)?
Anyone got any ideas.

cheers

H
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hello harry,

Phew...it should be possible but would require much effort. You should
override the OnPaint method (or handle the Pain event) of the DataGrid
control and provide manual painting for the column header you want to
customize.

Another challenge you are likely to encounter is determining the bounds of
the column header. While it is relatively easy task when a data cell is in
question (the grid exposes a GetCellBounds method), I am not so sure a
similar method exists for the headers.
 
H

Harry Longleat

Cheers, that's what I thought I'd have to do hoping that there was some
secret feature I hadn't found yet. I think I think this "feature" will
have to take a lower priority now.

H
 

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