也就是知道该Action的Name,现要设置其Enabled,如何写呢?
不要这样:TAction(ActionList1.Actions[i]).Enabled,因为i不知道

解决方案 »

  1.   

    var
      i,j:integer;
    begin
      i:=form1.ActionList1.ActionCount;
      for j:=0 to i-1 do
      begin
        if TAction(form1.ActionList1.Actions[j]).Name='EditCut1' then
          TAction(form1.ActionList1.Actions[j]).Enabled:=true;
      end;
    end;
      

  2.   

    直接这样写是不行的:form1.ActionList1.Action1.Enabled:=true;
      

  3.   

    循环有多慢?P3换成P4就好了//==================================
    //+          up是一种美德           +
    //==================================
      

  4.   

    Actionlist中的每个action是作为单独的TAction对象存在的,直接用名称就可以了啊。楼上的朋友那样就没有错啊。
    你看一下窗体的类的声明
    form1.Action1.Enabled:=true;//////////////////////////////////////////
    TForm1 = class(TForm)
        ActionList1: TActionList;
        Action1: TAction;//Action1就是名称啊,
        Action2: TAction;//直接用有什么不妥吗?
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;