Get First Node in a selection

Hi,

I want to find first Node in a linked chain of nodes.

This i can find out by checking each node source links count is zero or not?

But by problem is finding first node if you select only few nodes out of linked node and delete them.

I this case how can i check first node out of selected nodes and last node out of selection.

Basically from below picture if delete selected object i need to link block2 and block7.

I am planning to use view.SelectionDeleting event.

Please let me know your suggestions regarding my problem.

Regards,

Venkatesh

Instead of just checking for SourceLinks = 0, you need to check through each of the SourceLinks.FromNode to see if it is in the Selection.

This code will find all the “from” edge nodes… (and select them so you can see what it found)

private void buttonedges_Click(object sender, EventArgs e) {
  GoCollection edges = new GoCollection();
  foreach (GoObject o in CurrentView.Selection) {
    IGoNode n = o as IGoNode;
    if (n != null) {
      foreach (IGoLink sl in n.SourceLinks) {
        GoNode from = sl.FromNode as GoNode;
        if (!CurrentView.Selection.Contains(from)) {
          edges.Add(from);
        }
      }
    }
  }
  CurrentView.Selection.Clear();
  CurrentView.Selection.AddRange(edges);
}

}

Thanks jake. Its is working