Newbie here ...
I am using (TSimpleGraph v2.0) to generate some diagrams.
I have used the following code to link two nodes:
- Code: Select all
procedure TForm1.Button1Click(Sender: TObject);
const
NewNodeWidth = 100;
NewNodeHeight = 75;
var
NodeRect: TRect;
NewNode1,NewNode2: TGraphNode;
NewLink: TGraphLink;
begin
SimpleGraph.beginUpdate;
NodeRect.TopLeft := SimpleGraph.ClientToGraph(10,10);
NodeRect.Right := NodeRect.Left + NewNodeWidth;
NodeRect.Bottom := NodeRect.Top + NewNodeHeight;
NewNode1 := SimpleGraph.InsertNode(NodeRect, TRectangularNode);
NewNode1.Text := 'Test 1';
NodeRect.TopLeft := SimpleGraph.ClientToGraph(150,150);
NodeRect.Right := NodeRect.Left + NewNodeWidth;
NodeRect.Bottom := NodeRect.Top + NewNodeHeight;
NewNode2 := SimpleGraph.InsertNode(NodeRect, TRectangularNode);
NewNode2.Text := 'Test 2';
NewLink := SimpleGraph.InsertLink(NewNode1, NewNode2, TGraphLink);
SimpleGraph.EndUpdate;
end;
I can simply create the nodes but I stuck in linking them together. NewLink returns nil for some reason!
Why is that?
P.S. I don't want to update my graph component so please give me a solution without updating the current system. Thank you