Delphi - ControlListButton.OnClick - 如何从 ControlList 中确定 AIndex

Delphi - ControlListButton.OnClick - How to determine AIndex from ControlList

Delphi - ControlListButton.OnClick - 如何从 ControlList

中确定 AIndex

你好,我正在开发一个日历窗体,我正在尝试查找 ControlList 中的 ControlListButton 的索引。在 BeforeDrawItem 中,Label.Caption 设置为来自 ClientDataSet

的描述

ControlList.BeforeDrawItem 有一行使用 AIndex

procedure TFormCalendarViewMonthly.ControlListDayBeforeDrawItem(
  AIndex: Integer; ACanvas: TCanvas; ARect: TRect; AState: 
TOwnerDrawState);
  begin
    clientDataSet.RecNo:=AIndex;
   etc..
end;

ControlListButtonClick 仅与发件人一起显示。如何获取在 BeforeDraw 期间创建的点击的 AIndex?

procedure TFormCalendarViewMonthly.ControlListButtonClick(Sender: 
TObject);
  begin
   //AIndex is not part of the procedure
end;

我应该使用 ClientDataSet.RecNo 作为在 ControlList 中单击的行的索引吗?或者在 ButtonClick 中有没有办法查看被选中的行?

TControlList 当前选定的行可以从它的 ItemIndex 属性 中读取。