关于treeview的郁闷问题,请帮忙。。谢谢 ( 积分: 100 )

  • 主题发起人 主题发起人 ppaa
  • 开始时间 开始时间
P

ppaa

Unregistered / Unconfirmed
GUEST, unregistred user!
用treeview展开目录,双击该分区自动选择固定的目录:

我的电脑
c:本地磁盘
-0001
-0002
-0003
d:本地磁盘
-0001
-0002
-0003

双击代码
var
I: Integer;
begin
for I := 0 to LsDirTree101.Items.Count -1 do
begin
if LsDirTree101.Items.Text = '0001' then
begin
LsDirTree101.SetFocus;
LsDirTree101.Items.Selected := True;
LsDirTree101.Items.Item.Expand(true);
Break;
end;
end;
end;
///双击第一个分区正常,双击第二个分区,显示的仍然是第一个分区,请指点,非常感谢!!
 
procedure TForm1.Button1Click(Sender: TObject);
var
bFinish: Boolean;
function AutoSelect(RootNode: TTreeNode; var bFound: Boolean);
var
ANode: TTreeNode;
begin
if RootNode = nil then Exit;
ANode := RootNode.getFirstChild;
while not bFound and (ANode <> nil) do
begin
if ANode.HasChildren then AutoSelect(ANode, bFound);
if ANode.Text = '0001' then
begin
LsDirTree101.SetFocus;
ANode.Selected := True;
ANode.Expand(True);
bFound := True;
Break;
end;
ANode := ANode.getNextSibling;
end;
end;
begin
bFinish := False;
AutoSelect(LsDirTree101.Selected, bFinish);
end;
 
是procedure,sorry
 
非常感谢,不过编译不通过?
 
procedure TForm1.Button1Click(Sender: TObject);
var
bFinish: Boolean;
procedure AutoSelect(RootNode: TTreeNode; var bFound: Boolean);
var
ANode: TTreeNode;
begin
if RootNode = nil then Exit;
ANode := RootNode.getFirstChild;
while not bFound and (ANode <> nil) do
begin
if ANode.HasChildren then AutoSelect(ANode, bFound);
if ANode.Text = '0001' then
begin
LsDirTree101.SetFocus;
ANode.Selected := True;
ANode.Expand(True);
bFound := True;
Break;
end;
ANode := ANode.getNextSibling;
end;
end;
begin
bFinish := False;
AutoSelect(LsDirTree101.Selected, bFinish);
end;
前面不是说了是procedure,sorry
 
不是procedure的问题,

procedure AutoSelect(RootNode: TTreeNode; var bFound: Boolean);//这一行不过
 
请指教。。。谢谢
 
错误提示是什么
 
不好意思,没仔细看!!非常感谢!!分送出!!!!
 
后退
顶部