This is a migrated thread and some comments may be shown as answers.

How to get connected shapes for any selected Shape?

4 Answers 113 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Shrikant
Top achievements
Rank 1
Shrikant asked on 16 Jul 2012, 06:51 AM
Hi,
I want to know, how can I get child nodes for selected shapes?
For e.g.
A ---> A1-->A3,A4
A ---> A2-->A5,A6
Here A is root with two child's A1,A2.
So if I select A1 then I want to know which shapes are connected (i.e. outgoing links connected shapes from A1).

4 Answers, 1 is accepted

Sort by
0
Lancelot
Top achievements
Rank 1
answered on 16 Jul 2012, 03:40 PM
Hi Shrikant,

You can iterate over the items through items, shapes or connections. After getting a list, you can then look at the list of items and take it from there.

This link will bring you to the documentation on iteration of diagram items. Below is an example of how you would do it:

this.diagram.Shapes.ToList().ForEach(x =>
    {
        //your custom logic goes here
        (x as RadDiagramShape).Content = "Shape";
    });


Good Luck,
Lancelot
0
Accepted
Miro Miroslavov
Telerik team
answered on 18 Jul 2012, 06:32 AM
Hi Shrikant,

 There are some Extensions methods that you can use - GetConnectionsForShape(this IGraph graph, IShape shape) or IEnumerable<IConnection> GetOutgoingConnectionsForShape(this IGraph graph, IShape shape).
So the code will be something like this: 

var connectedShapes = diagram.GetOutgoingConnectionsForShape(myShape).Select(c => c.Target);

And the connectedShapes will contain the outgoing shapes of the myShape shape.

Kind regards,
Miro Miroslavov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Shrikant
Top achievements
Rank 1
answered on 04 Sep 2012, 11:23 AM
Hi Miro,
In current version of RadDiagram, I didn't found such a method to get connected shapes.
Can you check & tell me.

Thanks
0
Shrikant
Top achievements
Rank 1
answered on 06 Sep 2012, 08:10 AM
Sorry my mistake, assembly missing - "Telerik.Windows.Diagrams.Core"
Tags
Diagram
Asked by
Shrikant
Top achievements
Rank 1
Answers by
Lancelot
Top achievements
Rank 1
Miro Miroslavov
Telerik team
Shrikant
Top achievements
Rank 1
Share this question
or