Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting Entry of Text

Status
Not open for further replies.

gforrest

Programmer
Apr 26, 2000
39
CA
Hi,

I have a form with several edit boxes on it. The first box will always appear with text in it. The rest will be used for input. Is there a simple way to detect whether or not someone has entered text into an edit box and moreover, which edit box?

Thanks.
Glenn
 
Hi!
I hope, this little code will help you...

function ...Form.CheckEdits(var FirstFilled: TEdit): Boolean;
var
I: SmallInt;
begin
Result:= False;
FirtFilled:= nil;
{ go throught on all components of the form }
for I:=0 to ComponentCount-1 do
{ checks the component is TEdit? }
if Components is TEdit then
{ if TEdit, checks the Text property }
if TEdit(Components).Text<>'' then begin
FirstFilled:= TEdit(Components);
Result:= True;
break;
end;
end;


Otto
 
Or, have a change event for each edit box.

Eg, in properties of edit2, doubleclick OnChange event.

Should create

Procedure TForm1.Edit2Change(...);
Begin

End;

Insert your processing in the procedure:

Procedure TForm1.Edit2Change(...);
Begin
ShowMessage('Edit2 changed');
End;

Repeat for all edit boxes. You could set a variable in each and then call another procedure or function to process depending on which box was used.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top