当我按下按钮时,我试图将节点移动到顶部,TVirtualStringTree
所以我要做的第一件事是通过以下代码搜索节点
function Tform1.lookingTreeView(name: String): PVirtualNode;
var
Node: PVirtualNode;
Data: PUserData;
begin
Result := nil;
Node := Vts1.GetFirst;
while ((Node <> nil) and (Result = nil)) do
begin
Data := Vts1.GetNodeData(Node);
if (Tuserdataclass(Data.FObject).userUid = name) then
Result := Node;
Node := Vts1.GetNext(Node);
end;
end;
然后我将程序设置为能够检查节点是否等于例如“Martin”
procedure Tform1.checkmove;
var
Node: PVirtualNode;
Data: PUserData;
begin
Node := lookingTreeView(LineToid);
if not Assigned(Node) then
Exit;
if (Node <> nil) then
begin
Data := vts1.GetNodeData(Node);
if Tdataclass(Data.FObject).name = 'Martin' then
begin
// start move but dont know what to do to bring this node to first index
end;
end;
end;