Delphi VirtualStringTree Drawing
Asked Answered
V

2

1

I have been trying to figure these 2 things out:

1) How do I change the whole row's color in code? Like, when the VT looks like a ListView?

2) How do I make the Checkboxes indent aswell? My child checkboxes and on the same "indent?" as my root checkboxes.

Thanks!

Vilmavim answered 11/1, 2011 at 13:5 Comment(3)
Welcome to SO! Two questions should correspond to two questions on SO. What if someone knows the answer to one of your question? Does that qualify as an answer to your combined question?Pastor
1) And would you like to select the whole row or change each row background ?Interoffice
you may well be The 16 year old computer Wiz (sic), but really, couldn't you please use your real account here rather proliferating personas?!Estrous
I
2

1)

procedure VSTBeforeItemErase(
  Sender: TBaseVirtualTree; TargetCanvas: TCanvas; Node: PVirtualNode;
  ItemRect: TRect; var ItemColor: TColor;
  var EraseAction: TItemEraseAction);
begin
  EraseAction := eaColor;
  ItemColor := clLime;
end;

2) The indent setting for each node check box separately is IMHO impossible. The tree has its Indent property, which sets the indention for all nodes (including their check boxes). Internally the AdjustCoordinatesByIndent and PaintCheckImage methods are called, but both are hidden for you. Modification of one of them can help you, but you need to be very specific, I would say the best would be to create your own component descendant.

If you want to create something what is in property page of the advanced example, you need to add nodes to more than one level in the tree hierarchy.

For your inspiration ...

var CurrentNode: PVirtualNode;
    CurrentSubnode: PVirtualNode;

begin
  VirtualStringTree1.Indent := 50; // this increases indention for all nodes in the tree

  CurrentNode := VirtualStringTree1.AddChild(nil); // create a node to the root
  CurrentNode.CheckType := ctCheckBox; // check support of a node
  CurrentSubnode := VirtualStringTree1.AddChild(CurrentNode); // create a subnode to your first node
  CurrentSubnode.CheckType := ctCheckBox; // check support of a node
end;
Interoffice answered 11/1, 2011 at 13:16 Comment(0)
P
0

1) Try adding toFullRowSelect to TreeOptions.SelectionOptions.

2) I can't answer that. Maybe try toFixedIndent.

Pastor answered 11/1, 2011 at 13:16 Comment(1)
2) no, toFixedIndent indents all nodes to the same positionInteroffice

© 2022 - 2024 — McMap. All rights reserved.