AdvTreeView Find slected position and Text / Data

I have just startet my first AdvTreeView (with two columns) and filled Data from query. Thats ok.

At procedure

procedure Tfrm1.AdvTreeView1Click(Sender: TObject);
OR
procedure Tfrm1.AdvTreeView1DblClick(Sender: TObject);

a) i like to find the location of the node
b) i like to find the Text of Column1 und Column 2.

I know, the question is a beginner's question, but I can't find a working answer.
Sorry for asking this.

Beste regards
Rolf

You need to use one of the XYTo methods. as a parameter you can use the mouse cursor converted from screen to client

I am sorry - my english is so terrible ...

I'm looking for the content (the text) that is at the clicked position (not the XY position where the position is).

something like sValue := Edit.Text

see red marking on the attached picture
Value_of_AdvTreeViewNode

thank you again.
Rolf

procedure TForm2.AdvTreeView1Click(Sender: TObject);
var
  c: TPoint;
  cl: Integer;
  t: string;
  n: TAdvTreeViewVirtualNode;
begin
  c := Mouse.CursorPos;
  c := AdvTreeView1.ScreenToClient(c);
  n := AdvTreeView1.XYToNode(c.X, c.Y);
  if Assigned(n) then
  begin
    cl := AdvTreeView1.XYToNodeTextColumn(n, c.X, c.Y);
    if cl <> - 1 then
    begin
      t := n.Node.Values[cl].Text;
      OutputDebugString(pchar(t));
    end;
  end;
end;

Thats it!
Thank you very much, Pieter!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.