hi How to allow enter only 5 char in Tedit without using tmask?
Thanks.
especta 0 Newbie Poster
Recommended Answers
Jump to Posthi How to allow enter only 5 char in Tedit without using tmask?
Thanks.procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char); var T: string; begin T := Edit1.Text; if (Length(T)>4) and (Key<>#8) then Key := #0; end;
Key=#8 allows to be used BACKSPACE
Jump to PostIn case about pasting some text:
procedure TForm1.Edit1Change(Sender: TObject); var T: string; begin T := Edit1.Text; if (Length(T)>4) then begin Edit1.Text := Copy(T, 1, 5); Edit1.SelStart := 6; end; end;
All 6 Replies
finalist 1 Junior Poster in Training
especta commented: Thank you its help my very much +1
crystalbit 0 Newbie Poster
finalist 1 Junior Poster in Training
finalist 1 Junior Poster in Training
especta 0 Newbie Poster
crystalbit 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.