根据需要设置只读属性,以下代码为何总是不成立?在DELPHI中类似代码是可行的。
var i:integer;
begin
for i:=0 to self.ControlCount-1 do
begin
if ( Controls is TDataEdit ) then
(Controls as TDataEdit).ReadOnly:=Value;
if (Controls is TDataLocateComboBox) then
(Controls as TDataLocateComboBox).Enabled:=not Value;
if(Controls IS TDateTimePicker) THEN
(Controls as TDateTimePicker).Enabled:=not Value;
end;
end;
搞定,改用for i:=0 to ComponentCount-1 do
begin
if ( Components is TDataEdit ) then
(Components as TDataEdit).ReadOnly:=Value;
if (Components is TDataLocateComboBox) then
(Components as TDataLocateComboBox).Enabled:=not Value;
if(Components IS TDateTimePicker) THEN
(Components as TDateTimePicker).Enabled:=not Value;
end;就可以了。