Duplicate Image in VirtualStringTree Delphi

188 views Asked by At

I use a TVirtualStringTree component. With this code the image will show duplicated. How can I fix it?

duplicate icon

    procedure TFAbzarCode.VST1GetImageIndex(Sender: TBaseVirtualTree;
      Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
      var Ghosted: Boolean; var ImageIndex: TImageIndex);
    var
      NodeData: ^rTreeData;
      MImageIndex:integer;
    begin
      NodeData := Sender.GetNodeData(Node); 
      ImageIndex:=NodeData.ImageIndex;
    end;

I want only one icon beside the text

1

There are 1 answers

2
sh sh On

This code fixed the problem.

procedure TvTreeControl.vTreeGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer);
    var pNode  : PNodeRec;
    begin
         ImageIndex := -1;
         if Assigned(Node) then
              begin
              pNode  := Sender.GetNodeData( Node);
              if pNode.NodeData <> NIL then
                   begin
                   if Kind <> TVTImageKind(2)then
                        ImageIndex := pNode.NodeData.ImageIndex;
                   end;
              end;
    end;