how to Get RadDiagramShape by its name in c#?

2 posts, 0 answers
  1. Sachin
    Sachin avatar
    1 posts
    Member since:
    May 2017

    Posted 23 May 2017 Link to this post

    I am working on a project in which RadDiagramShape is generated dynamically in foreach loop.

     

    I need to change text of each Shape at each second. For that i need to access the Shape object by its name property which is unique. 

     

    How to i get RadDiagramShape object by its name?

     

  2. Hristo
    Admin
    Hristo avatar
    1519 posts

    Posted 23 May 2017 Link to this post

    Hi Sachin,

    Thank you for writing.

    The shapes are stored in a ShapeCollection object which is exposed by the RadDiagram.Shapes property. The ShapeCollection class inherits the System.Collections.ObjectModel.ReadOnlyCollection<T> class which cannot be enumerated by name.

    I can suggest to iterate your collection and search for the shape by its Name or use LINQ: 
    var shape = this.radDiagram1.Shapes.Where(s => s.Name == "YourName").FirstOrDefault();

    I hope this helps. Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top