Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxListItems.GetItemAtPos(TPoint) Method

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

#Declaration

Delphi
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