Intercepter la fin d'une édition d'un Node TreeView
Bonjour,
Comment peut-on intercepter la fin d'une édition d'un Node, J'aimerai récupéré le chemin d'accès de mon Node après édition (Renommer).
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| { GetFullPath }
function GetFullPath(Node: TTreeNode): String;
var
Root: String;
begin
Root := EmptyStr;
while Assigned(Node) do
begin
Root := Node.Text + '\' + Root;
Node := Node.Parent;
end;
Result := ExcludeTrailingBackslash(Root); // Node 1\Node 2\Node 3\TreeView.Selected
end; |
Code:
1 2 3 4 5 6 7 8 9 10
| procedure TForm1.TreeViewChange(Sender: TObject; Node: TTreeNode);
begin
Lab.Caption := GetFullPath(TreeView.Selected);
end;
procedure TForm1.TreeViewEdited(Sender: TObject; Node: TTreeNode;
var S: string);
begin
Lab.Caption := GetFullPath(Node);
end; |
TreeView.OnEditing : Se produit lorsque l'utilisateur commence à modifier la propriété Text d'un nœud.
TreeView.OnEdited : Se produit après que l'utilisateur a modifié la propriété Text d'un nœud.
C'est dommage qui n'ont pas créer un évènement EndEdited. :triste:
Merci.