我想点一个checkbox form里的edit都变灰, 有没有简单的方法?

解决方案 »

  1.   

    if checkbox.checked then
     form1.edit1.enabled:=false;
      

  2.   

    procedure TForm1.CheckBox1Click(Sender: TObject);
    var
      i:integer;
    begin
      for i:=0 to ComponentCount-1 do
      begin
        if (Components[i] is TEdit) then
        begin
          if CheckBox1.Checked then
            TEdit(Components[i]).Color := clGray
          else
            TEdit(Components[i]).Color := clBtnFace ;
        end;  end;
    end;
      

  3.   

    TEdit(Components[i]).Color := clWhite ;
      

  4.   

    procedure TForm1.CheckBox1Click(Sender: TObject);
    var
      i:integer;
    begin
      for i:=0 to ComponentCount-1 do
      begin
        if (Components[i] is TEdit) then
            TEdit(Components[i]).Enabled := not checkBox1.Check;
      end;
    end;
      

  5.   

    enable属性都改为false就变灰的~
    checkbox.enable:=false;
      

  6.   

    procedure TForm1.CheckBox1Click(Sender: TObject);
    var
      i:integer;
    begin
      for i:=0 to ContorlsCount-1 do
      begin
        if (Contorls[i] is TEdit) then
            TEdit(CContorls[i]).Enabled := not checkBox1.Check;
      end;
    end;
      

  7.   

    if checkbox.checked then  for I := ComponentCount - 1 downto 0 do
      begin
        if (Components[I] is TEdit) then
        begin
    ((Tedit)Components[I]).enabled:=false    end;
      end;
      

  8.   

    for i:=0 to controlcount-1 do
      if controls[i] is Tedit then 
        (controls[i] as Tedit).enabled:=false;
      

  9.   

    晕,理解错误
    haoco(程序员) 的代码就可以解决问题的
    列出 is 的帮助 
    The is operator, which performs dynamic type checking, is used to verify the actual runtime class of an object. The expressionobject is classreturns True if object is an instance of the class denoted by class or one of its descendants, and False otherwise. (If object is nil, the result is False.) If the declared type of object is unrelated to class梩hat is, if the types are distinct and one is not an ancestor of the other梐 compilation error results. For example,if ActiveControl is TEdit then TEdit(ActiveControl).SelectAll;This statement casts a variable to TEdit after first verifying that the object it references is an instance of TEdit or one of its descendants.
      

  10.   

    if checkbox.checked then  for I := ComponentCount - 1 downto 0 do
      begin
          if (Components[I] is TEdit) then
             begin
                ((Tedit)Components[I]).enabled:=false    
             end;
      endelse
      for I := ComponentCount - 1 downto 0 do
      begin
          if (Components[I] is TEdit) then
             begin
                ((Tedit)Components[I]).enabled:=true   
             end;
      end
      

  11.   


    放在checkbox的单击事件中:
    checkbox.checked:=not checkbox.checked;
    if checkbox.checked then 
    for i:=0 to controlcount-1 do
      if controls[i] is Tedit then 
        (controls[i] as Tedit).enabled:=false;
      

  12.   

    啊~~~~~~~~~亏了~
    原来是所有的edit啊!
    上面都有解决方案了~
      

  13.   

    for i:=0 to form4.ComponentCount-1 do
      begin
        if (Components[i] is TEdit)  then
            TEdit(Components[i]).Enabled := not TEdit(Components[i]).Enabled;
        if (Components[i] is Tcombobox) then
            Tcombobox(Components[i]).Enabled := not Tcombobox(Components[i]).Enabled;
      end;
      

  14.   

    来晚了,yangHONE(天涯)的可以解决,
    haoco(程序员)的会使edit不可用,
      

  15.   

    if checkbox.checked then
     form1.edit1.enabled:=false;
     form2.edit2.enabled:=false;
               3
               .
               .