View Single Post
  #16  
Old 12-04-2015, 07:23 AM
kolbasz kolbasz is offline
Senior Member
 
Join Date: Nov 2013
Posts: 841
Default

Quote:
For example, don't laugh , I search now the equivalent of ListView.ItemIndex. I read several Google finds without luck...
It take some time to get use to it, but after that you don't want to touch TListView again

Code:
var
  Node: PVirtualNode;
  Data: PData;
begin
  Node := VST.GetFirstSelected;
  if Node <> nil then 
  begin
     //since MultiSelect is not enabled, there is only one Node
    Data := VST.GetNodeData(Node);
    //Do something with Data    
  end;
end;
One more thing, I forget to free the nodes...To prevent memory leaks you should add the following to your code(OnFreeNode):
Code:
procedure TForm1.VSTFreeNode(Sender: TBaseVirtualTree; Node: PVirtualNode);
var
  Data: PData;
begin
  Data := Sender.GetNodeData(Node);
  Finalize(Data^);
end;
PS: There is a Node.Index property:
Code:
 Node := VST.GetFirstSelected;
 if Node <> nil then 
   ShowMessage(IntToStr(Node.Index));

Last edited by kolbasz; 12-04-2015 at 07:36 AM.
Reply With Quote