我正在使用VT.Background在VT中显示带有几列的背景图像.
但我无法找到一种方法为细胞使用不同的颜色,因为它们隐藏了背景图像.
我曾尝试使用,OnBeforeItemErase但如果我使用EraseAction := eaColor单元格上的背景位图区域也正在绘制,如果我使用eaDefault的颜色没有被应用.
知道如何做到这一点?
如何使用我自己的自定义按钮(图像)来替换VST中的默认[-]/ [+]按钮?
我想用箭头代替(
,
),还支持RTL bidi模式(
,
).
编辑:我知道bsTriangle样式(ButtonStyle).它不尊重RTL.我想使用自己的自定义图像.
好吧,我有以下问题:
我根据一些布尔变量绘制了不同颜色的树状单元格.例:
因此,在BeforeCellPaint中,我将基于那些布尔值绘制单元格背景颜色,如:
procedure TMainForm.ProcessVstBeforeCellPaint(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
var
NodeData: PProcessData;
begin
if Node = nil then
Exit;
NodeData := Sender.GetNodeData(Node);
if NodeData = nil then
Exit;
if (NodeData^.isProcessOwner) then
begin
TargetCanvas.Brush.Color := $00AAFFFF;
TargetCanvas.FillRect(TargetCanvas.ClipRect);
end;
if (NodeData^.isProcessInDebugger) then
begin
TargetCanvas.Brush.Color := $00E5A5A5;
TargetCanvas.FillRect(TargetCanvas.ClipRect);
end;
if (NodeData^.pProcessID = 0) or (NodeData^.pProcessID = 4) then
begin
TargetCanvas.Brush.Color := $00FFCCAA;
TargetCanvas.FillRect(TargetCanvas.ClipRect); … 如果我没弄错的话,TVirtualStringTree树视图中不可能有不可见的节点,因为没有启用,可见或其他属性.我这是对的吗?
如果是,我怎么设法有一个不可见的节点?
我树的结构:
当我在整个树上执行FirstNode/GetNextNode循环时,我可以找到子节点16,让我打印出第一列的文本.我也可以检查节点,看看他有一个以前的兄弟,但没有下一个兄弟,例如节点高度为18.
那我是怎么做到的?
我正在使用Delphi2010并尝试使用VirtualStringTree.
我一直试图让它与对象一起工作,并且在我遵循Philipp Frenzel的Virtual TreeView教程之前没有运气,我在soft-gems.net网站上找到了该教程.到目前为止我提出的工作原理,但我认为我没有正确处理子节点(即子节点).
我唯一能够工作的就是为每个孩子再次链接整个对象,然后只显示我需要的字段 - 但它只是感觉错了.
建议/反馈非常感谢.
我有一些对象列表,我正在尝试与VirtualStringTree连接,我正在尝试实现这样的事情,其中一个字段将作为父项的标签,其余字段显示为子节点.
这就是我班级的设置方式.
type
PTreeData = ^TTreeData;
TTreeData = record
FObject : TObject;
end;
TCustomerNode = class(TObject)
private
fName: string;
fSex: string;
fAge: integer;
fHair: string;
//...
public
property Name: string read fName write fName;
//...
end;
Run Code Online (Sandbox Code Playgroud)
一旦我填充了对象,我就将它们添加到另一个基于TList的类(CustomerObjectList),如下所述.
这是我将VirtualStringTree与我的对象列表连接的地方
procedure TfrmMain.btnLoadDataClick(Sender: TObject);
var
i, j : integer;
CustomerDataObject: TCustomerNode;
RootXNode, XNode: PVirtualNode;
Data: PTreeData;
begin
vstree.NodeDataSize := SizeOf( TTreeData );
vstree.BeginUpdate;
for i …Run Code Online (Sandbox Code Playgroud) 我想选择所有根节点或所有子节点(不是VirtualTreeView中的所有节点).
我试图使用此代码来选择所有根节点:
procedure SelectAllRoots;
var
Node: PVirtualNode;
begin
Form1.VirtualStringTree1.BeginUpdate;
Node := Form1.VirtualStringTree1.GetFirst;
while True do
begin
if Node = nil then
Break;
if not (vsSelected in Node.States) then
Node.States := Node.States + [vsSelected];
Node := Form1.VirtualStringTree1.GetNext(Node);
end;
Form1.VirtualStringTree1.EndUpdate;
end;
Run Code Online (Sandbox Code Playgroud)
我可以说有一个小故障.选择不完整或卡住.我究竟做错了什么 ?
编辑:
我使用MultiSelection.
检查节点是否可见很容易.但我不知道如何正确定义该节点在屏幕上显示.我只能这样发现:
BottomNode := Tree.BottomNode;
Node := Tree.TopNode;
IdBottomNode := Tree.AbsoluteIndex(BottomNode);
while Tree.AbsoluteIndex(Node) <> IdBottomNode do
begin
Node := Node.NextSibling;
if not Assigned(Node) then
Break;
end;
Run Code Online (Sandbox Code Playgroud)
(代码没有检查)
但我认为这是相当粗糙的方式.可能是有更准确的方法吗?
我正在使用TVirtualStringTree来存储指向记录的指针.
最初有一个包含记录列表的TList.
我正在使用OnInitNode事件迭代TList并将每个记录的数据分配给树的节点.
但是,在检索与OnNewText事件处理程序中的节点关联的数据时,返回的指针具有与最初存储在树中的指针不同的地址.
此外,我可以通过调试从节点中检索到的指针(该记录的数据)是看不一样最初存储在该节点的一个.我需要将更改的数据保存到数据库,并需要使用更改的数据引用记录.引用指针应该很简单,但问题是指针不一样.
我不确定我做错了什么,希望有人可以帮我解决这个问题.
提前致谢.
这是我的代码:
数据结构和声明:
TTherapData = record
TherapID: Integer;
TherapName: String[120];
TherapInstr: String[120];
Selected_DB: Byte;
Selected: Byte;
end;
PTherapData = ^TTherapData;
FTherapDataList: TList<PTherapData>;
FTherapDataListAsg_Iter: Integer;
vstRxList_Asg: TVirtualStringTree;
Run Code Online (Sandbox Code Playgroud)
将数据加载到TList中,然后加载到树中:
procedure TfmPatient_Conslt.LoadTherapList(const ADBLoad: Boolean = False);
var
TherapData: PTherapData;
d, x: Integer;
begin
datamod.uspLKTHERAP_S.First;
while not datamod.uspLKTHERAP_S.Eof do
begin
New(TherapData);
TherapData^.TherapID := datamod.uspLKTHERAP_SROW_ID.AsInteger;
TherapData^.TherapName := datamod.uspLKTHERAP_SIMPRTHERAP.AsString;
TherapData^.TherapInstr := EmptyStr;
TherapData^.Selected := 0;
TherapData^.Selected_DB := 0;
FTherapDataList.Add(TherapData);
datamod.uspLKTHERAP_S.Next;
end;
datamod.uspCONSLT_RX_S.First;
while not datamod.uspCONSLT_RX_S.Eof do
begin
d …Run Code Online (Sandbox Code Playgroud) 我有一个TVirtualStringTree以两种不同方式格式化节点文本的实例。实现基于使用toShowStaticText在StringOptions这个问题的答案接受描述:VirtualTreeView -不同颜色的文字在同一节点
在我MultiLine为节点设置标志之前,一切都很好。现在OnPaintText事件将不再被触发TextType = ttStatic。
这种行为的原因可以在TCustomVirtualStringTree.DoPaintNode方法中找到,显然是为了:
// ... and afterwards the static text if not centered and the node is not multiline enabled.
if (Alignment <> taCenter) and not (vsMultiline in PaintInfo.Node.States) and (toShowStaticText in TreeOptions.FStringOptions) then
begin
S := '';
with PaintInfo do
DoGetText(Node, Column, ttStatic, S);
if Length(S) > 0 then
PaintStaticText(PaintInfo, TextOutFlags, S);
end;
Run Code Online (Sandbox Code Playgroud)
不过,我希望在同一个MultiLineNode.js文件中有两种不同的文本格式。我怎样才能做到这一点?
我已设置FocusedNode使用以下代码的高度
procedure TMainForm.SetheightClick(Sender: TObject);
begin
if Assigned(tree1.FocusedNode) then
Tree1.NodeHeight[Tree1.FocusedNode] := strtointdef(edit8.Text ,50);
end;
Run Code Online (Sandbox Code Playgroud)
我想设置Tvirtualstringtree多选节点的高度.怎么做?