for i := 0 to MainMenu1.Items.Count - 1 do begin ListBox1.Items.Add(MainMenu1.Items[i].Caption); end;
ListBox不好,TreeView应该比较好。
function islbexist(addstr:string;lb:TListBox):boolean; var i:integer; begin if lb.Items.Count > 0 then begin for i:=0 to lb.Items.Count - 1 do begin if addstr = trim(lb.Items.Strings[i]) then begin result := true; exit; end else result:=false; end; end; end;
begin
ListBox1.Items.Add(MainMenu1.Items[i].Caption);
end;
var
i:integer;
begin
if lb.Items.Count > 0 then
begin
for i:=0 to lb.Items.Count - 1 do
begin
if addstr = trim(lb.Items.Strings[i]) then
begin
result := true;
exit;
end
else
result:=false;
end;
end;
end;