Creating links

Have 2 Nodes called BATMAN and SUPERMAN
Dim n1 as new GobasicNode
n1 = GoView1.Document.FindNode(“BATMAN”)
Dim n2 as new GobasicNode
n2 = GoView1.Document.FindNode(“SUPERMAN”)
How do I link them togeather?
Thanks

Since they are GoBasicNodes, they each have a single GoPort that you can connect using a GoLink:
Dim link As GoLink = new GoLink()
link.FromPort = n1.Port
link.ToPort = n2.Port
goView1.Document.LinksLayer.Add(link)
Of course you might want to set some properties on the link, such as:
link.ToArrow = true

Thanks.

In C# .NET 1.1 the FindNode method wants to return as a GoObject
(original posters example) so this code generates errors if it is
defined as a Node.

This works: GoObject n1 = goView1.Document.FindNode(“BATMAN”);

This doesn’t:
GoBasicNode n1 = new GoBasicNode();
n1 = goView1.Document.FindNode(“BATMAN”);

But the Link example in this thread requires a GoBasicNode object in order to properly get the GoPort.

How can I convert between the GoObject and GoBasicNode?

Cast it, either blindly:
GoBasicNode n1 = (GoBasicNode)goView1.Document.FindNode(“BATMAN”);
. . .
or wisely:
GoBasicNode n1 = goView1.Document.FindNode(“BATMAN”) as GoBasicNode;
if (n1 != null) { . . . }

Perfect! Thanks for the immediate response! It works like a charm! :)