not showing icon in virtualtreeview node fmx

  

I’m working on fmx virtualtreeview and trying to load image in nodes using TImageList but unfortunately image is not showing whereas I tested on vcl and it worked. Any help would be appreciated here is my code:

procedure TMainForm.VSTGetImageIndex(Sender: TBaseVirtualTree;Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;var Ghosted: Boolean; var ImageIndex: TImageIndex);
var
Data: PVSTData;
begin
Data := Sender.GetNodeData(Node);
if Kind in [ikNormal , ikSelected] then
begin
ImageIndex :=Data.ImageIndex;
end;
end;

procedure TMainForm.FormCreate(Sender: TObject);
var
c: char;
s: string;
DriveType: integer;
i: integer;
Data:PVSTData;
node:PVirtualNode;
begin
i:=0;
VST:= TVirtualStringTree.Create(Self);
VST.Parent:= Self;
VST.Images:=ImageList1;
VST.BorderStyle:=TFormBorderStyle.bsnone;
VST.Fill.Color:= TAlphaColorRec.White;
VST.Height:= 262;
VST.Align:= TAlignLayout.Top;
VST.OnInitNode := VSTInitNode;
VST.OnFreeNode := VSTFreeNode;
VST.OnGetText := VSTGetText;
VST.OnGetImageIndex:=VSTGetImageIndex;
VST.NodeDataSize := SizeOf(PVSTData);
for c:=’A’ to ‘Z’ do
begin
s:=c+’:’;
DriveType:=GetDriveType(PChar(s));
if DriveType=1 then continue;
System.Inc(i);
node:=AddChild(nil, s);
VST.HasChildren[node]:=True;
Data := Vst.GetNodeData(Node);
Data.ImageIndex:= i; //Added 4 icons in accordance with drives
end;
end;

Comments are closed.