if checkbox.checked then form1.edit1.enabled:=false;
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;
TEdit(Components[i]).Color := clWhite ;
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;
enable属性都改为false就变灰的~ checkbox.enable:=false;
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;
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;
for i:=0 to controlcount-1 do if controls[i] is Tedit then (controls[i] as Tedit).enabled:=false;
晕,理解错误 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.
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
放在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;
啊~~~~~~~~~亏了~ 原来是所有的edit啊! 上面都有解决方案了~
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;
来晚了,yangHONE(天涯)的可以解决, haoco(程序员)的会使edit不可用,
if checkbox.checked then form1.edit1.enabled:=false; form2.edit2.enabled:=false; 3 . .
form1.edit1.enabled:=false;
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;
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;
checkbox.enable:=false;
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;
begin
if (Components[I] is TEdit) then
begin
((Tedit)Components[I]).enabled:=false end;
end;
if controls[i] is Tedit then
(controls[i] as Tedit).enabled:=false;
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.
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
放在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;
原来是所有的edit啊!
上面都有解决方案了~
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;
haoco(程序员)的会使edit不可用,
form1.edit1.enabled:=false;
form2.edit2.enabled:=false;
3
.
.