🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.winforms.controls.using
4 messages
4 total messages Started by Ali Sat, 29 Jul 2006 06:12
A question about edit component
#218
Author: Ali
Date: Sat, 29 Jul 2006 06:12
5 lines
929 bytes
Dear All
Hi,
I have an edit component but I don't want to let user type alphabet in it.it should be filled by numbers only,how can I prevent from typing alphabets in this edit.
Thanks and regards
Re: A question about edit component
#221
Author: Marc Rohloff TeamB
Date: Sat, 29 Jul 2006 13:39
13 lines
1587 bytes
On 28 Jul 2006 23:12:41 -0700, Ali wrote:

> I have an edit component but I don't want to let user type alphabet in it.it should be filled by numbers only,how can I prevent from typing alphabets in this edit.
> Thanks and regards

Handle the KeyPress event with something like:

if key not in ('0'..'9', #8 {backspace}, #9 {tab} )
  then key := #0;

-- 
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com
Re: A question about edit component
#222
Author: Marc Rohloff TeamB
Date: Sat, 29 Jul 2006 13:44
14 lines
1523 bytes
On Sat, 29 Jul 2006 09:39:13 -0400, Marc Rohloff [TeamB] wrote:

> if key not in ('0'..'9', #8 {backspace}, #9 {tab} )
>   then key := #0;

Sorry I didn't realise that this is was a WinForms question.
The code should be:
 if e.KeyChar not in ('0'..'9', #8 {backspace}, #9 {tab} )
   then e.Handled := true;


-- 
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com
Re: A question about edit component
#223
Author: Marc Rohloff TeamB
Date: Sat, 29 Jul 2006 14:42
10 lines
1530 bytes
On 29 Jul 2006 07:02:30 -0700, Rudy Velthuis [TeamB] wrote:

>   if not (e.KeyChar in ['0'..'9', #8, #9]) then
>     e.Handled := True;

It works that way in Oracle <g>

-- 
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads