unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Mask;
type
TForm1 = class(TForm)
Button1: TButton;
MaskEdit1: TMaskEdit;
MaskEdit2: TMaskEdit;
MaskEdit3: TMaskEdit;
MaskEdit4: TMaskEdit;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
ControlValue: Integer;
MaskEditList: TList;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
ii: Integer;
Count: Integer;
begin
Count := MaskEditList.Count
ControlValue := StrtoInt(Edit1.Text);
if (ControlValue <= 0) or (ControlValue >Count) then Exit;
for ii := 0 to ControlValue-1 do
TMaskEdit(MaskEditList.Items[ii]).Enabled := True;
for ii := Controlvalue to Count-1 do
TMaskEdit(MaskEditList.Items[ii]).Enabled := False;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MaskEditList := TList.Create;
MaskEditList.Add(MaskEdit1);
MaskEditList.Add(MaskEdit2);
MaskEditList.Add(MaskEdit3);
MaskEditList.Add(MaskEdit4);
end;
end.