Board index » delphi » Restricting number of numbers typed in a cell in TStringGrid

Restricting number of numbers typed in a cell in TStringGrid

I want to restrict user from typing in a number with more than 3 digits.
 A one digit 2 digit or 3 digit number is acceptable. Any suggestions
would be much appreciated.

regards
Tony

 

Re:Restricting number of numbers typed in a cell in TStringGrid


Of course there are several other approaches to this. Some suggestions :

You could trigger on the keydown event and ignore all inputs after you have
got what you want.

You could make you a Mask property to the stringGrid class (whatever you
use.) Then you can set the Mask to whatever you want the user to input.
 Example:   3 digit Mask := 'iii' for integer values or '##.#' for a real
value with 2 digit before '.' and 1 after.
There are several components which do this. I use components from
http://www.turbopower.com  (Orpheus).

                   --
Edgar Vorland

{Remove  * from mail adress. This is to avoid
spawn. Sorry! }
e*vorl...@readmatre.no

Tony <ton...@dial.pipex.com> wrote in article
<33CD1F24.6...@dial.pipex.com>...

Quote
> I want to restrict user from typing in a number with more than 3 digits.
>  A one digit 2 digit or 3 digit number is acceptable. Any suggestions
> would be much appreciated.

> regards
> Tony

Re:Restricting number of numbers typed in a cell in TStringGrid


Quote
Tony wrote:
> I want to restrict user from typing in a number with more than 3
> digits.
>  A one digit 2 digit or 3 digit number is acceptable. Any suggestions
> would be much appreciated.

> regards
> Tony

How about using a filtered string and then using Val to equate it to a
number?

--

Martin Brooks - Systems Administrator
=====================================
Image Data Systems (UK) Ltd
82-84 Clerkenwell Road
London
EC1M 5RJ

  T: 0171 336 7942
  F: 0171 336 7943
  E: mar...@image-data.com
UIN: 2178117

- Computers make very fast, very accurate mistakes. -

Re:Restricting number of numbers typed in a cell in TStringGrid


Quote
Tony wrote:
> I want to restrict user from typing in a number with more than 3
> digits.
>  A one digit 2 digit or 3 digit number is acceptable. Any suggestions
> would be much appreciated.

> regards
> Tony

 If you are using a TEdit, you can set the MaxLength property to 3.

Rick Seiden
MrM...@aiusa.com

Other Threads