除了自增EDIT控件,还有通过两个Radiobutton来控制所有自增的Edit控件的Readonly属性,拜托高手们替我这个菜鸟解答,不甚感激

解决方案 »

  1.   

    sorry, Do not understand what you said!
      

  2.   

    我把代码发给你,你帮我看看啊这段代码是formcreat事件的:           Et : array of TEdit;(在全局中声明的)
       
       setlength(Et,200);
       for k := 1 to 7  do
           begin
              for j := 0 to 12 do
                  begin
                     Et[k + 7*j]              := TEdit.Create(self);
                     Et[k + 7*j].Parent       := self.GroupBox1;
                     Eh                       := 21;
                     Ew                       := 80;
                     Et[k + 7*j].Width        := 80;
                     Et[k + 7*j].Left         := 2 + 80*(k-1);
                     Et[k + 7*j].Top          := 34 + j*Eh;
                  end;
           end;
      我放了两个radiobutton共用一个onclick事件如下:
        procedure TForm1.RadioButton1Click(Sender: TObject);
    var
       m : integer;
    begin
       if RadioButton1.Checked = true then
          begin
             for m := 1 to Et[m].ComponentCount - 1 do
                 begin
                    Et[m].ReadOnly := true;
                 end;
          end;
    end;
      

  3.   

    procedure TForm1.RadioButton1Click(Sender: TObject);
    var
      m : integer;
    begin
      for m := 0 to self.ComponentCount - 1 do
        if self.Components[i]  is TEdit then
           TEdit(self.Components[i]).ReadOnly := RadioButton1.Checked;
    end;
      

  4.   

    SmallHand大哥,我把所有自增的edit组建都放在Groupbox里面而没有放在form里面,应该怎么写那段代码啊
      

  5.   

    procedure TForm1.RadioButton1Click(Sender: TObject);
    var
       m : integer;
    begin
       {for m := 0 to self.ComponentCount - 1 do
        if self.Components[m]  is TEdit then
           TEdit(self.Components[m]).ReadOnly := RadioButton1.Checked;
        }
        for m := 0 to GroupBox1.ControlCount - 1 do
            begin
               if GroupBox1.Controls[m] is TEdit then
                  begin
                     TEdit(GroupBox1.Controls[m]).ReadOnly := RadioButton1.Checked;
                  end;
            end;
    end;
    ,看这样可以吗?我想问下两者的不同之处啊?
      

  6.   

    procedure TForm1.RadioButton1Click(Sender: TObject);
    var
      m : integer;
    begin
      for m := 0 to self.ComponentCount - 1 do
        if (self.Components[i]  is TEdit) and (self.Components[i].parent=groupbox1) then
           TEdit(self.Components[i]).ReadOnly := RadioButton1.Checked;
    end;
      

  7.   

    sz_haitao大哥,你的代码里面的self.Components[i].parent报错说parent是没有声明的标志富啊
      

  8.   

    我把我源码给你看看啊unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, Buttons;type
      TForm1 = class(TForm)
        GroupBox1: TGroupBox;
        BitBtn1: TBitBtn;
        BitBtn2: TBitBtn;
        BitBtn3: TBitBtn;
        BitBtn4: TBitBtn;
        BitBtn5: TBitBtn;
        BitBtn6: TBitBtn;
        BitBtn7: TBitBtn;
        GroupBox2: TGroupBox;
        RadioButton1: TRadioButton;
        RadioButton2: TRadioButton;
        procedure FormCreate(Sender: TObject);
        procedure RadioButton1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      Et : array of TEdit;implementation{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
    var
       j, Eh, Ew ,k ,m : integer;
    begin
       setlength(Et,200);   {for k := 1 to 7  do
           begin
              for j := 0 to 12 do
                  begin
                     Et[k + 7*j]              := TEdit.Create(self);
                     Et[k + 7*j].Parent       := self.GroupBox1;
                     Eh                       := 21;
                     Ew                       := 80;
                     Et[k + 7*j].Width        := 80;
                     Et[k + 7*j].Left         := 2 + 80*(k-1);
                     Et[k + 7*j].Top          := 34 + j*Eh;
                  end;
           end;}
       for j := 0 to 12 do
           begin
              Et[1 + 7*j]              := TEdit.Create(self);
              Et[1 + 7*j].Parent       := self.GroupBox1;
              Et[1 + 7*j].ReadOnly     := true;
              Eh                       := 21;
              Et[1 + 7*j].Width        := 143;
              Et[1 + 7*j].Left         := 2;
              Et[1 + 7*j].Top          := 34 + j*Eh;
           end;
       for j := 0 to 12 do
           begin
              Et[2 + 7*j]              := TEdit.Create(self);
              Et[2 + 7*j].Parent       := self.GroupBox1;
              Eh                       := 21;
              Et[2 + 7*j].Width        := 109;
              Et[2 + 7*j].Left         := 145;
              Et[2 + 7*j].Top          := 34 + j*Eh;
           end;
       for k := 3 to 6  do
           begin
              for j := 0 to 12 do
                  begin
                     Et[k + 7*j]              := TEdit.Create(self);
                     Et[k + 7*j].Parent       := self.GroupBox1;
                     Eh                       := 21;
                     Ew                       := 75;
                     Et[k + 7*j].Width        := 75;
                     Et[k + 7*j].Left         := 254 + 75*(k-3);
                     Et[k + 7*j].Top          := 34 + j*Eh;
                  end;
           end;end;
    procedure TForm1.RadioButton1Click(Sender: TObject); 
    var 
      m : integer; 
    begin 
      if RadioButton1.Checked = true then 
          begin 
            for m := 1 to Et[m].ComponentCount - 1 do 
                begin 
                    Et[m].ReadOnly := true; 
                end; 
          end; 
    end; 
      

  9.   


    if (self.Components[i]  is TEdit) and (Tedit(self.Components[i].parent)=groupbox1) then