Hi i've a project that uses the VirtualStringTree , with this Record :
Delphi-Quellcode:
type
TStudentsSession = record
StudentName : String;
StudentClass : String;
StudentHandRaised:Boolean;
end;
And i've these Procedures :
Delphi-Quellcode:
Procedure TMainForm.StudentHandRaised(AStudentName:String)
var
Node:PVirtualNode;
Data:^TStudentsSession;
begin
Node:=StudentsVst.GetFirst;
while Node<>nil do begin
Data:=StudentsVst.GetNodeData(Node);
if Data.StudentName=AStudentName then
begin
Data.StudentHandRaised:=True;
Break;
end ;
Node:=StudentsVst.GetNext(Node);
end;
end;
Procedure TMainForm.StudentHansDown(AStudentName:String)
var
Node:PVirtualNode;
Data:^TStudentsSession;
begin
Node:=StudentsVst.GetFirst;
while Node<>nil do begin
Data:=StudentsVst.GetNodeData(Node);
if Data.StudentName=AStudentName then
begin
Data.StudentHandRaised:=False;
Break;
end ;
Node:=StudentsVst.GetNext(Node);
end;
end;
We Have these 4 Students in Order:
StudentA
StudentB
StudentC
StudentD
What i want is this :
* StudentB raises his Hand :
StudentB
StudentA
StudentC
StudentD
* StudentC raises his Hand :
StudentB
StudentC
StudentA
StudentD
StudentC will not Jump on StudentB ( Because StudentB is still raising his Hand )
* StudentD raises his Hand :
StudentB
StudentC
StudentD
StudentA
StudentC will not Jump on StudentB or StudentC ( Because both are still raising their Hands )
* StudentB withdraws his hand :
StudentC
StudentD
StudentA
StudentB
* StudentB will be moved to the last position
I tried to use this procedure :
Delphi-Quellcode:
procedure TMainForm.ReArrangeStudents;
var
Node,PreviNode: PVirtualNode;
Data:^TStudentsSession;
begin
Node:=StudentsVst.GetFirst;
while Node<>nil do begin
Data:=StudentsVst.GetNodeData(Node);
if Data.StudentHandRaised Then
PreviNode :=StudentsVst.GetPrevious(Node,false)
else PreviNode := StudentsVst.GetNext(Node);
StudentsVst.MoveTo(Node,PreviNode,amInsertBefore,false);
Node:=StudentsVst.GetNext(Node);
end;
end;
But this ends with always jumping to the First position .
So please can some one helps me to Do the correct Order .