Single Link

I would like to only allow a LinkPoint to have only one (or zero) Lines attached to it. 


I have been messing arround with all the events I think might be of use such as OnLinkAdded, OnAcceptAnchor, OnAcceptLink but I can't get anything to work.

Can anyone help?

What is the code you tried for OnAcceptAnchor? This should be the most appropriated event. Basically you should do this (not tested):

 
procedure TMyForm.DiagramAcceptAnchor(Sender: TObject; ALink, AAnchor: TLinkPoint;
    var Accept: boolean);
begin
  Accept := ((AAnchor.AnchoredCount = 0)) or ((AAnchor.AnchoredCount = 1) and (AAnchor.Anchoreds[0] = ALink));
end;

Thanks Wagner, That worked perfectly.


Diagram Studio seems to be a very powerful component but unfortunately the I sometimes feel the help and examples are not much help to mere mortals like myself!! (or maybe I am just too dumb to be allowed to write programs) For example, the help files for OnAcceptAnchor says "You can also use this event to avoid the link to be performed." But there are no clues about how this could be done!

David.