New to Telerik UI for WinFormsStart a free 30-day trial

Custom Shapes

Updated over 6 months ago

To create a custom shape you need to inherit the ElementShape class and override the CreatePath method. In it you should create and return the shape path. For example the following code creates a cross shape.

C#
public class CrossShape : ElementShape
{
    public CrossShape()
    {
        this.Width = 20;
    }
    public override GraphicsPath CreatePath(Rectangle bounds)
    {
        GraphicsPath path = new GraphicsPath();
        path.AddRectangle(new RectangleF(bounds.X, (bounds.Y + bounds.Height / 2) - Width / 2, bounds.Width, Width));
        path.AddRectangle(new RectangleF((bounds.X + bounds.Width / 2) - Width / 2, bounds.Y, Width, bounds.Height));
        path.CloseFigure();
        return path;
    }
    public int Width { get; set; }
}

Figure 1 shows the result from the above code. the shape is applied to a RadPanel.

Figure 1: The cross shape.

custom-shape001

See Also

In this article
See Also
Not finding the help you need?
Contact Support