Now I wanted to have another property in the custom stylist to set the foreground color (font color) of the headers. However, it seems that the text is drawn in the Grid-component, so it doesn't look like I can customize this in the stylist? I could set the foreground color of the grid (which I can access through StylistDrawInfo.Control) inside the Draw-function of the stylist when I need to redraw the headers, but won't this affect performance, since it will be doing this with every redraw? Are there other solutions?
Currently you can dynamically provide context dependent foreground colors of colum headers via Column object:
[c#]
public class ColoredHeaderColumn : Column
{
//...
public override Color ForeColor
{
get
{
return (State & ColumnState.MouseDown) != 0 ?
SystemColors.Desktop :
base.ForeColor;
}
}
}
or provide your own fore color (what you can set in Stylist without redrawing, currently painted Column instance is provided in StylistDrawInfo.Context):
[c#]
public class ColoredHeaderColumn : Column
{
//...
private Color myForeColor = Color.Empty;
public override Color ForeColor
{
get
{
return !myForeColor.IsEmpty ?
myForeColor :
base.ForeColor;
}
}
//to reset custom fore color and use standard ForeColor simply set it to Color.Empty
public void SetMyOwnForeColorWithoutInvalidate(Color color)
{
myForeColor = color;
}
}