Skip to main content

TdxListItems.GetItemAtPos(TPoint) Method

Provides access to an individual list item at the specified position.

Declaration

function GetItemAtPos(const P: TPoint): TdxListItem;

Parameters

Name Type Description
P TPoint

A point in the client area of the parent List View control.

Returns

Type Description
TdxListItem

The list item at the target position (P).

The function returns nil (in Delphi) or nullptr (in C++Builder) if the target point (P) does not belong to a list item in the current collection.

Remarks

Call the GetItemAtPos function to identify a list item by a point within the parent List View control’s client area.

Code Example: Display Clicked Item Captions

The code example in this section demonstrates an OnMouseDown event handler that displays the clicked list item‘s caption in the application form’s title bar:

procedure TMyForm.dxListViewControl1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  ATargetItem: TdxListItem;
begin
  if Button = mbLeft then
  begin
    ATargetItem := dxListViewControl1.Items.GetItemAtPos(Point(X, Y));
    if ATargetItem <> nil then
      Caption := 'Target Item is ' + ATargetItem.Caption;
  end;
end;
See Also