Re:Don't let TEdit beep on ENTER
Quote
music4 wrote:
> When press ENTER in a TEdit, it will beep. I want this, so I would create my
> own component inherited from TEdit. But I don't know override which
> procedure or function to forbid the beep on ENTER key. Please help if you
> know.
I'm assuming you meant to say "I DON'T want this,...".
You don't really need to create a new component, just use the OnKeyPress
event:
procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
Key := #0;
end;
If you do create a new component, override the KeyPress method and do
the same thing. A more general (and perhaps more useful) TEdit
descendant would be able to prevent any key(s) specified, by publishing
a "ForbiddenKeys" TStrings property.
--
jc