# How to get connected shapes for any selected Shape?

1. ##### Shrikant
38 posts
Member since:
Jul 2011

Posted 16 Jul 2012 Link to this post

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).
2. ##### Lancelot
251 posts
Member since:
Jul 2012

Posted 16 Jul 2012 Link to this post

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
##### Miro Miroslavov
588 posts

Posted 18 Jul 2012 Link to this post

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

4. ##### Shrikant
38 posts
Member since:
Jul 2011

Posted 04 Sep 2012 Link to this post

Hi Miro,
In current version of RadDiagram, I didn't found such a method to get connected shapes.
Can you check & tell me.

Thanks
5. ##### Shrikant
38 posts
Member since:
Jul 2011

Posted 06 Sep 2012 Link to this post

Sorry my mistake, assembly missing - "Telerik.Windows.Diagrams.Core"