Delphi VirtualStringTree Drawing

一个人想着一个人 提交于 2019-12-11 10:49:47

问题


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!


回答1:


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;



回答2:


1) Try adding toFullRowSelect to TreeOptions.SelectionOptions.

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



来源:https://stackoverflow.com/questions/4657915/delphi-virtualstringtree-drawing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!