这是我一个用户管理控件的部份代码:
procedure TUser.CollectMenuItem(item: TMenuItem;var Count: Integer);
var I : integer;
strCaption : String;
begin
for I := 0 to Item.Count -1 do
begin
if Item.Items.Caption <> '-' then
begin
Inc(Count);
strCaption := Item.Items.Caption;
if pos(' ',strCaption) > 0 then
strCaption := Copy(strCaption,1,Pos(' ',strCaption) -1);
end;
end;
这样行不行?
for i:=0 to ComponentCount-1 do
begin
if(Components is TMenuItem) then
begin
qryGetMenuVisible.First; //查询到的菜单数据集
while not qryGetMenuVisible.eof do
begin
if(qryGetMenuVisible.FieldByName('MenuName').AsString=(components as TMenuItem).Name) then
begin
if(qryGetMenuVisible.FieldByName('Visible').AsString='可见') then
(Components as TMenuItem).Visible:=true
else
(Components as TMenuItem).Visible:=false;
end;
qryGetMenuVisible.Next;
end;
end;
end;