How to set Caption back color in UltraGrid?
CaptionAppearance.BackColor doesn't work.
My UltraGrid version is 11.1.20111.2020
private void Form1_Load(object sender, EventArgs e) { this.ultraGrid1.DrawFilter = new MyDrawFilter(); }
public class MyDrawFilter : IUIElementDrawFilter { bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { drawParams.AppearanceData.BackColor = Color.Red; return false; } DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is CaptionAreaUIElement) return DrawPhase.BeforeDrawBackColor; return DrawPhase.None; } }
Thanks Mike.
The first option did work with some side effect as you suggested it might.
The second option doesn't do what I need as I have to use Grid Caption.
As for the third option I will spend time to explore.
Hi Steve,
By default, the style library overrides any settings in the application. If it didn't, it would be useless for existing applications where Appearance settings where already applied. You can change this by setting the Resolution Order on control within the Isl. But that might not be a good solution since there are likely to be other Appearances in your application that you probably want the style library to override.
If you want to try it, open your isl file in AppStylist.
In the Roles tree, expand Component Roles. Then either select All Components or expand Infragistics Components and select UltraWinGrid.
In the properties on the bottom, find the ResolutionOrder property. Try setting it to ControlThenApplication. This will make the control settings override the Isl.
Another option would be to set the Appearance on individual objects like each column header instead of the CaptionAppearance on the DisplayLayout.Individual object settings will take precedence over the style library, since it makes sense to want to set the color on a single row, cell, or in this case header.
Still a third option would be to use a DrawFilter.
Ok, I know it is loading an ISL file. But I cannot find the color setting for Caption. Besides, why these 2 lines of code cannot override it at run-time as I want to set it to different color at different time?
Grid.UseOsThemes = DefaultableBoolean.False;Grid.DisplayLayout.CaptionAppearance.BackColor = Color.Yellow;
Red? Well... it seems unlikely that themes would be turning the header red, anyway. My guess is that something else in your application is doing that. Maybe you are loading a style library in the grid. Look for StyleManager.Load.