Skip to main content

TcxCustomTreeView.GetNodeAt(Integer,Integer) Method

Gets the node located under the specified point.

Declaration

function GetNodeAt(X: Integer; Y: Integer): TTreeNode;

Parameters

Name Type
X Integer
Y Integer

Returns

Type
TTreeNode

Remarks

Use the GetNodeAt method to obtain the TTreeNode object representing the node located under the specified point. The point is specified by its horizontal and vertical coordinates via X and Y parameters respectively. Note that the control’s client coordinates must be specified. If you have screen coordinates, you should use the ScreenToClient method of the control to obtain client coordinates.

The GetNodeAt method is most commonly used to obtain the node located under the mouse pointer. This can be used, for instance, to display additional information about nodes within the status bar when pointing to nodes with the mouse pointer. If you need to determine which element of the node is under the mouse pointer, use the GetHitTestInfoAt method.

The following sample code handles the OnMouseMove event of the tree view control. This is used to display node captions within the status bar when the mouse pointer points to them. Note that you need a status bar with at least one section created on your form to use the code below.

procedure TForm1.cxTreeView1MouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
var
  Node: TTreeNode;
begin
  Node := cxTreeView1.GetNodeAt(X, Y);
  if Node = nil then
    StatusBar1.Panels[0].Text := ''
  else
    StatusBar1.Panels[0].Text := Node.Text;
end;

Here is the result of code execution:

See the ToolTips and GetHitTestInfoAt topics for other examples of using the GetNodeAt method.

See Also