Hello all,
Can the individual WinGrid columns have separate fonts assigned to them in code? As an example, if I wanted to make the selected coumn header text Bold or a different color, can I do that? If so, how do I get to the column Font? Thanks in advance for any ideas and/or suggestions!
Hello Mike,
Thanks for the additional explanation and sample code. That was very helpful.
These properties already exist. They are on the Appearance object.
If you want to change the font of a header of column, you just set something like this:
grid.DisplayLayout.Bands[0].Columns["column key"].Header.Appearance.FontData.Bold = DefaultableBoolean.True;
For the column itself, you would use the CellAppearance on the column.
You don't need an event unless you want to dynamically change the appearance based on the current state of the grid.
I'm not really sure exactly what you are trying to do here. Do you really want the "selected" column to have a different appearance? If so, when do you mean by "selected?" Do you mean the column of the active cell? If so, be careful about mixing up "active" and "selected", as they are two different things.
Thanks for the clarification!
Any chance that things like Font could be added to the grid Column and ColumnHeader object properties so that it would be a little bit more intuitive and a lot easier to use? Without help from the forums, it would have taken me a long time to figure out that I needed to use this event to change font settings.
Presumably enabling sorting precludes column selection. You mentioned the "selected column header" so I assumed you were somehow selecting the column. In any case, the appearances used in the code sample I provided are not tied to selection; you can set them arbitrarily on any column at any time.
Hello Brian,
When I tried to use your sample code, it was not fired when I clicked the column headers, only when I clicked in the grid data area. In the latter case, it will never be a column header. When I clicked the column header, it sorted, as I would have expected.