I'm trying to use FMX.TreeView with CheckBoxes, but can't find a way how to identify item, which fired TreeViewChangeCheck event.
All solutions I found were about VCL.ComCtrls TreeView with TTreeNode class, but I am using FMX.TreeView.
Can anybody help me? Thanks.
The OnChangeCheck
event is of class TNotifyEvent
. Its Sender: TObject
parameter tells you who triggered the event. For example, the following code
procedure TForm19.TreeView1ChangeCheck(Sender: TObject);
begin
ShowMessage(Sender.ToString);
end;
might show TTreeViewItem 'TreeViewItem5'
Or, if you want to change a property of that item,
procedure TForm19.TreeView1ChangeCheck(Sender: TObject);
begin
if Sender is TTreeViewItem then
if TTreeViewItem(Sender).IsChecked then
TTreeViewItem(Sender).Text := 'Checked'
else
TTreeViewItem(Sender).Text := 'Not checked';
end;
Or, if you really want the index of the item:
ShowMessage(IntToStr((Sender as TTreeViewItem).Index));