Ich verwende dafür diese Funktion (relevant ist hier
TcxCustomTreeListControl.FindNodeByText
):
Delphi-Quellcode:
//------------------------------------------------------------------------------
function FindStringInTreeView(Sender : TcxTreeList; Value : string; SearchForward : boolean = true) : boolean;
//------------------------------------------------------------------------------
// Inline function for finding a string within the treeview
//------------------------------------------------------------------------------
var
FoundNode, ParentNode : TcxTreeListNode;
begin
result := false;
with Sender do
begin
FoundNode := TreeList.FindNodeByText(Value,Columns[1], FocusedNode, false, SearchForward);
if FoundNode <> nil then
begin
result := true;
ParentNode := FoundNode;
while ParentNode.Parent <> nil do
begin
ParentNode := ParentNode.Parent;
ParentNode.Expanded := true;
end;
FocusedNode := FoundNode;
end;
end;
end;