Author: Tomas Rutkauskas
I want to check if the user has filled all required DBEdit controls on a notebook,
before enabling a button on the form.
Answer:
If you dropped the controls onto the notebook at design time, their Owner will be
the form not the notebook. This means that it will not belong to the Components
array of the notebook, but of the form. The Notebook's Controls array will be all
the controls it parents and that is probably the array you want to loop through.
1 procedure TAddFrm.SetNextBtn;
2 var3 I: Integer;
4 fld: TControl;
5 fldEmpty: Boolean;
6 begin7 fldEmpty := False;
8 with Notebook do9 begin10 for I := 0 to ControlCount - 1 do11 begin12 fld := Controls[i];
13 if (fld is TDBEdit) then14 begin15 fldEmpty := TDBEdit(fld).GetTextLen = 0;
16 if fldEmpty then17 Break;
18 end19 end;
20 AddfrmNextBtn.Enabled := not fldEmpty;
21 end;
22 end;
23 24 if fldName is TCustomEdit then25 fldEmpty := TCustomEdit(fldName).GetTextLen = 0;