var
 i,count:integer;
 arr:array[1..10] of integer;
begin
case included of
  0:
  begin
   with form1.ADOQuery1 do
   begin
   sql.Clear;
   sql.Add('select count(*) as count from ConR where included=:included');//ConR是权限配置表,
                                                                                       included是角色代号
   parameters.ParamByName('included').Value:=included;//登录时记录的角色代号
   open;
   count:=fieldbyname('count').AsInteger;   sql.Clear;
   sql.Add('select distinct RID from ConR where included=:included');//权限ID
   parameters.ParamByName('included').Value:=included;
   open;
   end;
   for i:=1 to count do
   begin
   arr[i]:=strtoint(form1.ADOQuery1.fieldbyname('RID').AsString );//把权限ID存入数组
   if 条件 then
   begin
   //这里应该怎么写?我想通过菜单里各个子菜单的Tag值跟权限ID比较,如果相等就显示该菜单
   end;
   end;
  end;
  1:
  begin
  ......
  end;
end;
end;

解决方案 »

  1.   

    var  i : Integer;begin
      for i := 0 to MainMenu1.Items.Count - 1 do
      case MainMenu1.Items[i].Tag of
        0 : ;//
        1 : ;//
        2 : ;//
      else
        ShowMessage('aaa');
      end;
    end;这是枚举菜单 tag 的代码
      

  2.   


    for i := 1 to MainMenu1.Items.Count-1 do
    begin
       if MainMenu1.Items[j].tag=count then
         begin
           MainMenu1.Items[j].Enabled := true;
           MainMenu1.Items[j].Visible := true;
         end
       else
         begin
           MainMenu1.Items[j].Enabled := false;
           MainMenu1.Items[j].Visible := false;
         end; 
    end;大概这是样,细节楼主自己修改哦
      

  3.   

    一楼不要CASE,这样太累,如果有N多种可能性难道还都全部列出来??