I've got a grid which has the font size set fairly large. The columns with a Checkbox column style, are showing with a fairly small checkbox - the sort of size that would fit nicely for the default font size, but which look completely lost inside the cell. Is there a way of changing the size of the checkbox used by the grid cell?
Thanks,
Sue
Mike,
Thanks for the quick response and the great code, works perfectly!
-Chris
Hi Chris,
It's not the ClipRect you want, it's the Rect.
Here's some sample code which sets the rect to the biggest possible rect that fits inside the parent and is still square.
private void Form1_Load(object sender, EventArgs e) { // Themed checkboxes cannot be resized, so in order to resized the // checkboxes, we must turn off themes. // this.ultraGrid1.UseOsThemes = DefaultableBoolean.False; this.ultraGrid1.CreationFilter = new CheckBoxCreationFilter(); } public class CheckBoxCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { if (parent is CheckEditorCheckBoxUIElement) { UIElement checkIndicatorUIElement = parent.GetDescendant(typeof(CheckIndicatorUIElement)); if (checkIndicatorUIElement != null) { int maxExtent = Math.Min(parent.Rect.Width, parent.Rect.Height); int newX = parent.Rect.X + ((parent.Rect.Width - maxExtent) / 2); int newY = parent.Rect.Y + ((parent.Rect.Height - maxExtent) / 2); Rectangle rect = new Rectangle( newX, newY, maxExtent, maxExtent ); checkIndicatorUIElement.Rect = rect; } } } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { // do nothing return false; } #endregion }
Can you please provide some code for the CreationFilter to change the checkbox size. The ClipRect property on the CheckIndicatorUIElement is read only, and can't figure out how to adjust
Thanks in advance
Hi Sue,
It depends what kind of style you are using for you checkboxes. If your application is using themes, which is the default on operating systems that support themes, then you cannot change the size of the CheckBox, because Windows themes don't allow it.
If you are not using themes (or you don't mind turning them off), then you have two options.
1) You can use a CreationFilter to change the size of the CheckBoxIndicatorUIElement in the cell.
2) You can use use an UltraCheckEditor and use the GlyphInfo property to replace the default checkboxes with images you supply. Then you set the EditorComponent on the grid column to the UltraCheckEditor control.
If you'd rather go with option 1, so that you don't have to draw the images yourself, let me know and I can help you with the CreationFilter code.