Hi,
I have a boolean type column in the grid and set its style to checkbox. Also I set its header checkbox visibility property to Always to enable the header checkbox. In order to apply some custom style on the default checkbox in the column, I added a checkbox Editor and set the column's EditorComponent property as this custom checkbox Editor. Now all the cells except the header cell can display as this custom Editor's style. How can I change the style of header checkbox? Looking forward to your feedbacks.
FYI. I'm using version NetAdvantage 2010.1.
What exactly is your custom style doing? Are you simply changing the appearance of the checkbox? Are you assigning a GlyphInfo? Are you using images?
The column header checkbox doesn't support editors. But you can set the glyphs on a control or application level. If you are using images, then you can probably achieve what you want using a DrawFilter or CreationFilter. But it's impossible to say what the best approach is without knowing what you are trying to change.
Thanks for you reply, Mike.
I want to assign office 2007 style glyphs to the checkbox. Also I don't want to apply this feature to the application level. Is it possible only apply this glyph to the column fo grid or the grid level. I can't find a related property on the column or the grid.
Thanks,
Kun
Hi Kun,
There's no way to do this on the Column level.
And the only way to do this on the grid level would be to use AppStylist. Are you already loading an Application Style Library (isl) file into your application?
Now that you point this out, it seems like something of an oversight. We should probably expose a property by which you can set the Glyphs for header checkboxes on the grid.
Unfortunately, the version you are using is retired, so that wouldn't help you unless you wanted to upgrade.
I was able to do this using a CreationFilter to change the UIElements for the Checkindicators to a new derived UIElement. What I did is I created a class that derives from CheckIndicatorUIElement and I overrode BeforeDrawForeground to change the current GlyphInfo just while the drawing operation is taking place for the particular element.
Then I use a CreationFilter to replace the usual CheckIndicatorUIElements in the grid column headers with my derived element.
public class Office2007CheckIndicatorCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { HeaderCheckBoxUIElement headerCheckBoxUIElement = parent as HeaderCheckBoxUIElement; if (headerCheckBoxUIElement != null) { Office2007CheckIndicatorUIElement checkIndicatorUIElement = null; if (parent.ChildElements.Count > 0) { checkIndicatorUIElement = parent.ChildElements[0] as Office2007CheckIndicatorUIElement; parent.ChildElements.Clear(); } if (checkIndicatorUIElement == null) { checkIndicatorUIElement = new Office2007CheckIndicatorUIElement(headerCheckBoxUIElement); } checkIndicatorUIElement.Rect = parent.RectInsideBorders; parent.ChildElements.Add(checkIndicatorUIElement); return true; } // do nothing return false; } #endregion } public class Office2007CheckIndicatorUIElement : CheckIndicatorUIElement { public Office2007CheckIndicatorUIElement(CheckBoxUIElement parent) : base(parent, parent) { } protected override void DrawForeground(ref UIElementDrawParams drawParams) { GlyphInfoBase originalGlyphInfoBase = UIElementDrawParams.CheckBoxGlyphInfo; UIElementDrawParams.CheckBoxGlyphInfo = UIElementDrawParams.Office2007CheckBoxGlyphInfo; try { base.DrawForeground(ref drawParams); } finally { UIElementDrawParams.CheckBoxGlyphInfo = originalGlyphInfoBase; } } protected override bool DrawTheme(ref UIElementDrawParams drawParams) { return false; } }
All that's left to do is set the CreationFilter on the grid.You could do this in the Form_Load.
this.ultraGrid1.CreationFilter = new Office2007CheckIndicatorCreationFilter();
It is great! Thanks for your reply. Really appreciate your help on it.