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!
One possible solution:
this.ultraGrid.BeforeSelectChange += new BeforeSelectChangeEventHandler(ultraGrid_BeforeSelectChange);
void ultraGrid_BeforeSelectChange(object sender, BeforeSelectChangeEventArgs e){ UltraGrid grid = sender as UltraGrid;
if ( e.Type == typeof(Infragistics.Win.UltraWinGrid.ColumnHeader) ) { if ( grid.Selected.Columns.Count == 1 ) grid.Selected.Columns[0].Appearance.Reset();
if ( e.NewSelections.Columns.Count == 1 ) { e.NewSelections.Columns[0].Column.Header.Appearance.FontData.Bold = DefaultableBoolean.True; e.NewSelections.Columns[0].Column.Header.Appearance.ForeColor = Color.Red; } }}
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.
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.
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.
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.
Hello Mike,
Thanks for the additional explanation and sample code. That was very helpful.