Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
Checkbox Style
posted

I was hoping to edit the style of the checkmark in the UltraCheckboxEditor for WindowsForms.  Can anyone help me with this?

  • 19308
    posted

    NOTE: The information in this post show's the "hard way", read Mike's response to find out how to use the CheckedAppearance.Image property to acheive the same thing. 

    I suspect you're looking to replace the checkmark with a custom glyph?  If this is the case, you will need to use a DrawFilter to take over painting of the checkbox area.  DrawFilters are basically hooks into the painting routine for any given UIElement.  In this case, you'll want to use the CheckIndicatorUIElement and either override the BeforeDrawElement phase, or paint over top of the checkmark using the AfterDrawElement phase.  Here's a stubbed out version that takes complete control over painting the checkbox.

        private void Form1_Load(object sender, EventArgs e)

            {

               this.ultraCheckEditor1.DrawFilter = this;   

            }

     

            #region IUIElementDrawFilter Members

     

            public bool DrawElement(Infragistics.Win.DrawPhase drawPhase, ref Infragistics.Win.UIElementDrawParams drawParams)

            {

                //get the rectangle we need to draw in

                Rectangle elementRect = drawParams.Element.Rect;

                //T"ODO Draw Custom checkbox and glyph here

                return true;

            }

     

            public Infragistics.Win.DrawPhase GetPhasesToFilter(ref Infragistics.Win.UIElementDrawParams drawParams)

            {

                //Use the CheckIndicatorUIElement and listen for the BeforeDrawElement phase

                if (drawParams.Element is Infragistics.Win.CheckIndicatorUIElement)

                    return Infragistics.Win.DrawPhase.BeforeDrawElement;

                return Infragistics.Win.DrawPhase.None;           

            }