Question

I have downloaded and installed TSimpleGraph component but cannot really understand how to use it. I've checked the demo but it is too complexed for me and in Delphi (I use C++ Builder) to be able to dissect what I need.

What I am trying is to create two rectangles that are connect with an arrow line. Rectangles should be able to move when user drags them and the arrow should move accordingly (pointing from one rectangle to another). If someone could provide me with this example (Delphi or C++ Builder) I believe I could figure out the rest. Thanks in advance.

Was it helpful?

Solution

procedure TForm1.FormCreate(Sender: TObject);
var
  Node: TRectangularNode;
  Link: TGraphLink;
begin
  FGraph := TSimpleGraph.Create(Self);
  FGraph.SetBounds(10, 10, 400, 400);
  FGraph.BeginUpdate;
  Node := TRectangularNode.Create(FGraph);
  Node.SetBounds(25, 25, 100, 50);
  Node := TRectangularNode.Create(FGraph);
  Node.SetBounds(200, 200, 50, 100);
  Link := TGraphLink.Create(FGraph);
  Link.Link(FGraph.Objects[0], FGraph.Objects[1]);
  FGraph.EndUpdate;
  FGraph.Parent := Self;
end;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top