【问题标题】:Delphi VirtualStringTree DrawingDelphi VirtualStringTree 绘图
【发布时间】:2011-01-11 13:05:46
【问题描述】:

我一直试图弄清楚这两件事:

1) 如何更改代码中整行的颜色?比如,当 VT 看起来像 ListView 时?

2) 如何使复选框也缩进?我的孩子复选框和同一个“缩进?”作为我的根复选框。

谢谢!

【问题讨论】:

  • 欢迎来到 SO!两个问题应该对应于关于 SO 的两个问题。如果有人知道您的某个问题的答案怎么办?这是否可以作为您综合问题的答案?
  • 1) 您想选择整行还是更改每行背景?
  • 你很可能是 16 岁的计算机奇才(原文如此),但说真的,你不能在这里使用你的真实帐户来增加角色吗?!

标签: delphi listview virtualtreeview


【解决方案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) 每个节点复选框的缩进设置单独恕我直言是不可能的。 树有它的 Indent 属性,它设置所有节点的缩进(包括它们的复选框)。 在内部调用了 AdjustCoordinatesByIndent 和 PaintCheckImage 方法,但是这两个方法对你来说都是隐藏的。修改其中一个可以帮助您,但您需要非常具体,我会说最好是创建自己的组件后代。

如果要创建高级示例的属性页中的内容,则需要将节点添加到树层次结构中的多个级别。

为了你的灵感......

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) 尝试将toFullRowSelect 添加到TreeOptions.SelectionOptions

    2) 我无法回答。 也许可以试试toFixedIndent

    【讨论】:

    • 2) 不,toFixedIndent 将所有节点缩进到同一位置
    猜你喜欢
    • 1970-01-01
    • 2013-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-28
    • 1970-01-01
    相关资源
    最近更新 更多