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
335
UltraPanel top border only
posted

Hi

I would like to put a border at the top of an ultrapanel. Is it possible to have the border (a solid line) at just the top of the ultrapanel?

Thanks

Paul

Parents
  • 1560
    Verified Answer
    Offline posted

    Hello Paul,


    My suggestion for achieving your requirement is using DrawFilter. In the DrawFilter class implementation you can create a pen with color and width as you need and draw line only on top of the Panel.
     

    public class DrawFilter : IUIElementDrawFilter
        {
            Pen borderPen = new Pen(Color.DarkGoldenrod, 15);
            public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
            {
                // If the element being drawn is a ControlUIElementBase
                // we're interested in drawing its borders only.
                Rectangle elementRect = drawParams.Element.Rect;
                drawParams.Graphics.DrawLine(this.borderPen,
                  elementRect.Location,
                  new Point(elementRect.Right, elementRect.Top));
                // Return true to prevent the element from drawing
                // its borders normally.
                return true;
            }
     
            public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams)
            {
                if (drawParams.Element is ControlUIElementBase)
                    return DrawPhase.BeforeDrawElement;
                return DrawPhase.None;
            }
        }
     

    I have attached a sample application that uses this approach. Please test it on your side and let me know if I may be of any further assistance. 

    Sincerely,
    Teodosia Hristodorova
    Associate Software Developer

    0602.Top_Border_UltraPanel.zip

Reply Children