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!

Nik Reiman
  • 39,067
  • 29
  • 104
  • 160
  • 6
    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? – jpfollenius Jan 11 '11 at 13:13
  • 1) And would you like to select the whole row or change each row background ? –  Jan 11 '11 at 13:30
  • 1
    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?! – David Heffernan Jan 11 '11 at 20:48

2 Answers2

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;
0

1) Try adding toFullRowSelect to TreeOptions.SelectionOptions.

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

jpfollenius
  • 16,456
  • 10
  • 90
  • 156