create a triangle shape programatically

2 posts, 1 answers
  1. Carolina
    Carolina avatar
    3 posts
    Member since:
    Oct 2012

    Posted 28 Jul 2015 Link to this post

    I would create a triangle type figure and add it to RadDiagram control all this programmatically, can anyone help?

    I'm using the class RadDiagramShape the problem is not that I put in the ElementShape property, I welcome your comments.

  2. Answer
    Dimitar avatar
    1337 posts

    Posted 29 Jul 2015 Link to this post

    Hi Carolina,

    Thank you for writing.

    We do not have a predefined triangle shape, but you can easily create one. All you need to do is to inherit the ElementShape class and return the desired figure path:
    public class Triangle : ElementShape
        public override GraphicsPath CreatePath(Rectangle bounds)
            GraphicsPath path = new GraphicsPath();
            Point top = new Point(bounds.X + bounds.Width / 2, bounds.Y);
            Point right = new Point(bounds.X + bounds.Width, bounds.Y + bounds.Height);
            Point left = new Point(bounds.X, bounds.Y + bounds.Height);
            path.AddPolygon(new Point[]
            return path;

    Then you can create the diagram shape like this:
    private void radButton1_Click(object sender, EventArgs e)
        RadDiagramShape shape1 = new RadDiagramShape()
            Text = "",
            ElementShape = new Triangle(),
            BackColor = Color.LimeGreen
        shape1.Position = new Telerik.Windows.Diagrams.Core.Point(100, 100);

    Another example for this is available in he following article: Shapes.

    Please let me know if there is something else I can help you with. 

  3. DevCraft banner
Back to Top