Recent

Author Topic: [SOLVED] Is there a component like TEdit that only takes numbers in?  (Read 17392 times)

Elmug

  • Hero Member
  • *****
  • Posts: 849
I am building based on TEdit a way to have a pane or display which only takes numbers and the decimal point, and backspace to delete.

Then wondered if there is already such thing included, or else.

Seems to me like that is common in data entry where only numbers can be input. Basically to input real numbers, and up to a certain limit.

If it is not included, I am kind of surprised, because there are so many widgets included, and this one would be so useful.

Thanks for guideance!
« Last Edit: July 19, 2011, 12:46:12 am by Elmug »

DirkS

  • Sr. Member
  • ****
  • Posts: 251
Re: Is there a component like TEdit that only takes numbers in?
« Reply #1 on: July 17, 2011, 08:36:34 am »
Have a look at TMaskEdit (http://lazarus-ccr.sourceforge.net/docs/lcl/maskedit/tmaskedit.html).
It's part of the standard install

Gr.
Dirk.

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Is there a component like TEdit that only takes numbers in?
« Reply #2 on: July 17, 2011, 08:41:45 am »
Have a look at TMaskEdit (http://lazarus-ccr.sourceforge.net/docs/lcl/maskedit/tmaskedit.html).
It's part of the standard install

Gr.
Dirk.

Thanks DirkS,

Will see if can make sense out of it.

Bart

  • Hero Member
  • *****
  • Posts: 5706
    • Bart en Mariska's Webstek
Re: Is there a component like TEdit that only takes numbers in?
« Reply #3 on: July 17, 2011, 12:02:11 pm »
While MaskEdit certainly is an option, it also has one drawback: the length of the mask is also the max number of digits a user can input.

If you want a robust input for Integers/Floats then I would take a look at TFloatSpinEdit and TSpinEdit instead.
These also have the advantage of having a property Value, thus relieving you of the task of converting text to integer or float: it's all done automagically for you.

Bart

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Is there a component like TEdit that only takes numbers in?
« Reply #4 on: July 17, 2011, 12:41:24 pm »
While MaskEdit certainly is an option, it also has one drawback: the length of the mask is also the max number of digits a user can input.

If you want a robust input for Integers/Floats then I would take a look at TFloatSpinEdit and TSpinEdit instead.
These also have the advantage of having a property Value, thus relieving you of the task of converting text to integer or float: it's all done automagically for you.

Bart

Hi and thanks.

Is TFloatSpinEdit a little Entry/Display window similar to TEdit window that I can place in Form1?
If so, where do I drag it into the form from?

Thanks.

Bart

  • Hero Member
  • *****
  • Posts: 5706
    • Bart en Mariska's Webstek
Re: Is there a component like TEdit that only takes numbers in?
« Reply #5 on: July 17, 2011, 05:01:21 pm »
It's on the "Misc" tab.
Just drop it on a form and play with it.
It's really easy.

Bart

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Is there a component like TEdit that only takes numbers in?
« Reply #6 on: July 17, 2011, 06:23:09 pm »
This might suit you better

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Is there a component like TEdit that only takes numbers in?
« Reply #7 on: July 17, 2011, 07:11:57 pm »
Thanks everyone.

I just checked the Mis components and will see what they do. I also have downloaded the link leledumbo suggests and will check all this out. :)

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Is there a component like TEdit that only takes numbers in?
« Reply #8 on: July 17, 2011, 07:32:15 pm »
I think TFloatSpinEdit is what I was looking for.

BUT, is there one that DOES NOT have the Increment-Decrement arrows?

Although it looks like they can be disabled, would like to see if there's one without the arrows.

Thanks everyone.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Is there a component like TEdit that only takes numbers in?
« Reply #9 on: July 18, 2011, 07:18:59 pm »
Extends TIntegerEdit from FshComp to allow float input ;)

 

TinyPortal © 2005-2018