//假设你有三个菜单项,tag分别为18,19,20
procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
for I:=0 to form1.ComponentCount-1do
if Components is TmenuItem then
if TmenuItem(Components).tag in [18,19,20] then
TmenuItem(Components).enabled:=false;
end;
procedure TForm1.SetMenuItemState(pItemName :string;pState :Boolean);
var iIndex :integer;
begin
for iIndex :=0 to Form1.ComponentCount-1do
begin
if Form1.Components[iIndex] is TMenuItem then
begin
ShowMessage((Form1.Components[iIndex] as TMenuItem).Caption);
if (Form1.Components[iIndex] as TMenuItem).Caption = pItemName then
begin
(Form1.Components[iIndex] as TMenuItem).Enabled :=pState;
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SetMenuItemState(Edit1.text,false);
end;
//但必须保证 frm_main.AutoLineReduction :=maManual;