我遍历树,找到了一个结点,怎样才能让这个结点高亮度显示?
如果只有用发消息的办法,加80分procedure TFrmTopoTree.BitBtn4Click(Sender: TObject);
var
FirstNode,PreNode,xx,v_node:TTreeNode;
PreNodes:Tlist;
IfFind:Boolean;
i:integer;
begin
TreeVGeography.Items.BeginUpdate;
TreeVGeography.FullCollapse;
IfFind:=False;
FirstNode:=TreeVGeography.Items.GetFirstNode;
v_node:=TreeVGeography.Items.GetFirstNode;
while v_node<>nil do
begin
if UpperCase(Trim(v_node.Text))=UpperCase(Trim(ComboBox.Text)) then
begin
IfFind :=True;
break;
end;
ListBox1.Items.Add(v_node.Text );
v_node :=v_node.GetNext;
end;
if IfFind then
begin
xx:=v_node ;
PreNodes:=Tlist.Create ;
try
while xx.Text <>FirstNode.Text do
begin
xx:=xx.Parent ;
PreNodes.Add(xx);
end;
for i:= PreNodes.Count-1 downto 0 do
BEGIN
TTreeNode(PreNodes.Items[i]).Expand(False);
END;
finally
PreNodes.Free ;
end;
end;
TreeVGeography.Items.EndUpdate ; //TreeVGeography.Selected :=v_node.text;
treevgeography.Selected.Text :=v_node.text;
TreeVGeography.Selected.SelectedIndex:=3; if not IfFind then
begin
Application.MessageBox('ûÓÐÕÒµ½ÄãÒª²éÕÒµÄÍøÔª£¡', 'ϵͳÌáʾ', mb_ok or MB_ICONINFORMATION);
exit;
end;
end;
如果只有用发消息的办法,加80分procedure TFrmTopoTree.BitBtn4Click(Sender: TObject);
var
FirstNode,PreNode,xx,v_node:TTreeNode;
PreNodes:Tlist;
IfFind:Boolean;
i:integer;
begin
TreeVGeography.Items.BeginUpdate;
TreeVGeography.FullCollapse;
IfFind:=False;
FirstNode:=TreeVGeography.Items.GetFirstNode;
v_node:=TreeVGeography.Items.GetFirstNode;
while v_node<>nil do
begin
if UpperCase(Trim(v_node.Text))=UpperCase(Trim(ComboBox.Text)) then
begin
IfFind :=True;
break;
end;
ListBox1.Items.Add(v_node.Text );
v_node :=v_node.GetNext;
end;
if IfFind then
begin
xx:=v_node ;
PreNodes:=Tlist.Create ;
try
while xx.Text <>FirstNode.Text do
begin
xx:=xx.Parent ;
PreNodes.Add(xx);
end;
for i:= PreNodes.Count-1 downto 0 do
BEGIN
TTreeNode(PreNodes.Items[i]).Expand(False);
END;
finally
PreNodes.Free ;
end;
end;
TreeVGeography.Items.EndUpdate ; //TreeVGeography.Selected :=v_node.text;
treevgeography.Selected.Text :=v_node.text;
TreeVGeography.Selected.SelectedIndex:=3; if not IfFind then
begin
Application.MessageBox('ûÓÐÕÒµ½ÄãÒª²éÕÒµÄÍøÔª£¡', 'ϵͳÌáʾ', mb_ok or MB_ICONINFORMATION);
exit;
end;
end;
TreeVGeography.SetFocus;
没有这个方法 TreeVGeography.SelectAll;
TreeVGeography.SetFocus
TreeVGeography.SetFocus ;
treevgeography.Selected :=v_node;