Delphi - ControlListButton.OnClick - How to determine AIndex from ControlList
Hello I am developing a calendar form and I am trying to find the Index of a ControlListButton that is within a ControlList. In the BeforeDrawItem the Label.Caption is set to a description from a ClientDataSet
ControlList.BeforeDrawItem has a row that uses AIndex
procedure TFormCalendarViewMonthly.ControlListDayBeforeDrawItem(
AIndex: Integer; ACanvas: TCanvas; ARect: TRect; AState:
TOwnerDrawState);
begin
clientDataSet.RecNo:=AIndex;
etc..
end;
The ControlListButtonClick only shows with Sender. How do I get the AIndex of the click that was created during the BeforeDraw?
ie.
procedure TFormCalendarViewMonthly.ControlListButtonClick(Sender:
TObject);
begin
//AIndex is not part of the procedure
end;
Should I use the ClientDataSet.RecNo as the Index for the Row that was clicked in the ControlList? Or is there a way in the ButtonClick to see the row that was selected?
CodePudding user response:
The currently selected row of a TControlList
can be read from its ItemIndex
property.