How to create Dynamic GoLabeledLinks


#1

Does anyone know how to programatically create a GoLabeledLink between 2 nodes? I’m using the ASP.Net version. The following code works, but if I change the GoLink to a GoLabeledLink, my app stops processing any further lines without generating an exception.
Dim myLink As GoLink
myLink = MyView.CreateLink(MasterNode.Port, ChildNode.Port)
Cheers
Graham.


#2

Yes, you can’t just change the declared type of a local variable and expect the system to behave in the way you want. GoLabeledLink does not inherit from GoLink, because GoLabeledLink inherits from GoGroup and GoLink inherits from GoStroke/GoShape.
You should instead tell the GoView that it ought to be creating a GoLabeledLink by setting:
MyView.NewLinkClass = GetType(GoLabeledLink)


#3

Thanks walt.
The NewLinkClass method does the trick.
Just to clarify, I wasn’t casting the GoLink to a GoLabeledLink and hoping for the best. I was changing the line ‘Dim myLink as GoLink’ to ‘Dim myLink as GoLabeledLink’ and rebuilding the app.
The CreateLink method returns an object of type IGoLink, and as both GoLink and GoLabeledLink implement this interface, (and given the absence of good examples), it’s natural to assume that declaring myLink as a GoLabeledLink type would work.