Occurs when the Caption property for a node is about to change.
Write an OnNodeCaptionChange event handler to take some action when the caption is about to change.
Namespace: GGraph
Delphi
|
public
property OnNodeCaptionChange: TNodeCaptionEvent read FOnNodeCaptionChange write FOnNodeCaptionChange;
|
Value
Type: TNodeCaptionEvent
The following code keeps a list box synchronized with a graph. The listbox contains all the nodes in the graph:
Delphi
|
procedure TForm1.AddNode( Sender: TObject; ANode: TGGraphNode );
begin
ListBox1.Items.AddObject( ANode.Caption, ANode );
end;
procedure TForm1.RemoveNode( Sender: TObject; ANode: TGGraphNode );
begin
ListBox1.Items.Delete( ListBox1.Items.IndexOfObject( ANode ) );
end;
procedure TForm1.NodeCaptionChange( Sender: TObject; ANode: TGGraphNode; var NewCaption: String );
begin
ListBox1.Items[ ListBox1.Items.IndexOfObject( ANode ) ] := NewCaption;
end;
begin
// connect the events to the graph
Graph.OnAddNode := AddNode;
Graph.OnNodeCaptionChange := NodeCaptionChange;
Graph.OnRemoveNode := RemoveNode;
end;
|
|