I'm looking to change the font of one button (so that it stands out( in my winforms app, but am having limited success. I have tried changing the font size, colour, and making it bold - the size and bold seems to work at runtime, but the app style seems to override the colour.
Is there a way of making this stick? Overriding the application style for just this one button?
Thanks.
Thanks Mike,
The draw filter is a much neater solution. Yes, I'll only use it for the font colour.
fweeee said:Is there no other way of doing this? Some sort of fancy appearance filter or something?
Well, you could use a DrawFilter. I would not recommend changing the font size this way, because the control's AutoSize won't account for the change. But if it's just the color you want, it should be a pretty easy DrawFilter:
this.ultraButton1.DrawFilter = new MyButtonDrawFilter();
public class MyButtonDrawFilter : IUIElementDrawFilter { bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { drawParams.AppearanceData.ForeColor = Color.Red; return false; } DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is TextUIElementBase) return DrawPhase.BeforeDrawForeground; return DrawPhase.None; } }
Thanks Mike.
I have tried turning off the appStylist on the button, but it made it kind of ugly.
I'm concerned about edting the appstyle - this might have unintended consequenses - as in, the appearance of some buttons may change (depending on how their properties are currently set).
Is there no other way of doing this? Some sort of fancy appearance filter or something?
Hi,
AppStylist will override any properties that are explictly set by the style library. So if your style library is setting a ForeColor, but not a size or the bold state, then you will get the behavior you describe.
You could turn off AppStylist on the button (by setting UseAppStylist to False, assuming it's an UltraButton).
Or, you could set your ResolutionOrder in the Isl File to ControlThenApplication, so the control's settings take precedence over the isl.