procedure TCustomTreeView.Edit(const Item: TTVItem);
var
S: string;
Node: TTreeNode;
begin
with Item do
begin
Node := GetNodeFromItem(Item);
if pszText <> nil then
begin
S := pszText;
if Assigned(FOnEdited) then FOnEdited(Self, Node, S);
if Node <> nil then Node.Text := S;
end
else if Assigned(FOnCancelEdit) then FOnCancelEdit(Self, Node);
end;
end;
function TCustomTreeView.GetNodeFromItem(const Item: TTVItem): TTreeNode;
begin
Result := nil;
if Items <> nil then
with Item do
if (state and TVIF_PARAM) <> 0 then
Result := Pointer(lParam)
else
Result := Items.GetNode(hItem);
end;