Is there a component like TEdit that only takes numbers in? lazarus / 31-LCL ---------------------------------------------------------------------- mandeepmavi · 2012-06-08 21:03 Hello friends. Looking for a component like TEdit that only takes numbers in? I tried SpinEdit but this have UP DOWN arrow which i do not need. or can i disable or remove. I am unable to install Fshcomp on v0.9.30. tried lots of things but no luck. Or any other method to enter Number from keyboard and buttons on panel. Thakns ---------------------------------------------------------------------- Bart · 2012-06-08 21:08 Try T(Float)SpinEdit. I think it's on the [Misc]-Tab Bart ---------------------------------------------------------------------- Avishai · 2012-06-08 21:16 You can use TEdit.  I was in a hurry so this code is not pretty but it will show you how. procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: char); begin   case Key of     '0'..'9': begin end;   else Key:= #0;   end; end; ---------------------------------------------------------------------- Bart · 2012-06-08 21:38 Why would you insist on using a TEdit when a custom made component for editing integers and floats is already available and has the advantage of a Value property? Bart ---------------------------------------------------------------------- Avishai · 2012-06-08 21:40 No one is insisting on anything. ---------------------------------------------------------------------- mandeepmavi · 2012-06-08 21:48 Thanks friends, 1, Avishai good idea but with this Backspace is also diabled. 2. Bart i tried TSpinEdit but this one have a increment arrows which i do not need. ---------------------------------------------------------------------- Avishai · 2012-06-08 22:04 procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: char); begin   case Key of     '0'..'9': ;     #8: ;  // the backspace key   else Key:= #0;   end; end; You can add whatever Keys you want to allow to the Case statement. '+','-','.' or any other key. ---------------------------------------------------------------------- mandeepmavi · 2012-06-08 22:07 Good Job, i will try. and will do some exercise if it work. Thanks ---------------------------------------------------------------------- felipemdc · 2012-06-09 07:17 Maybe TMaskEdit could solve this issue too. Not sure, however since I rarely use it. ---------------------------------------------------------------------- Bart · 2012-06-09 15:20 Quote from: felipemdc on June 09, 2012, 09:17:05 amMaybe TMaskEdit could solve this issue too. Not sure, however since I rarely use it. You would have to specify a mask like '9999999;1;_' , but as you can see this isn't very flexible when it comes to the amount of numbers the user can enter in the control. Bart ---------------------------------------------------------------------- r_1gm · 2012-06-12 06:57 How about RX Component TCurrencyEdit ? ---------------------------------------------------------------------- sylvanus67 · 2012-06-12 09:11 What about http://wiki.lazarus.freepascal.org/Fshcomp ? ---------------------------------------------------------------------- JD · 2012-06-24 16:01 Quote from: r_1gm on June 12, 2012, 08:57:25 amHow about RX Component TCurrencyEdit ? This one does the job. For integer values, just set 'DecimalPlaces' to zero. ---------------------------------------------------------------------- mandeepmavi · 2012-06-29 21:11 JD is there any example RX Component TCurrencyEdit. it is giving hard time if i test with negitive number. ---------------------------------------------------------------------- mandeepmavi · 2012-06-29 22:09 Unable to multiply price with quantity for total var   Price: Double; begin     if RadioButton1.Checked then      begin      Price := (CurrencyEdit1.Text)  *  StrToFloat(Edit11.Text));      CurrencyEdit2.Text:=FloatToStr(Price); Please any idea ---------------------------------------------------------------------- taazz · 2012-06-29 22:13 Quote from: mandeepmavi on June 30, 2012, 12:09:01 amUnable to multiply price with quantity for total var   Price: Double; begin     if RadioButton1.Checked then      begin      Price := (CurrencyEdit1.Text)  *  StrToFloat(Edit11.Text));      CurrencyEdit2.Text:=FloatToStr(Price); Please any idea Text * float??? How About CurrencyEdit1.Value instead or strtoFLoat(CurrencyEdit1.Text)? ---------------------------------------------------------------------- Avishai · 2012-06-29 23:28 Maybe something like this. Price := StrToFloat(CurrencyEdit1.Text)  *  StrToFloat(Edit11.Text)); ---------------------------------------------------------------------- typo · 2012-06-30 04:29 There is no component like this because it is very easy to make it. Anyway, if you are just checking about viability, feel free to work on it. ---------------------------------------------------------------------- paweld · 2012-07-01 21:14 http://wiki.freepascal.org/jujiboutils or http://www.lazarusforum.de/downloads.php?view=detail&df_id=36 ---------------------------------------------------------------------- Avishai · 2012-07-01 21:21 Mr. paweld, do you know if these controls support BiDiMode? ---------------------------------------------------------------------- paweld · 2012-07-01 23:29 jujiboutils support BiDiMode ---------------------------------------------------------------------- denver · 2012-07-02 09:14 Many years ago. I found an open source fnpnumericedit.pas for delphi. I port it to lazarus. Give it a try. ---------------------------------------------------------------------- Avishai · 2012-07-07 20:01 I must agree with Mr. typo on this.  This is too easy to do with code to justify adding a new component.  Just use TEdit and the OnKeyPress and add whatever keys you want to allow. ---------------------------------------------------------------------- taazz · 2012-07-07 22:42 Quote from: Avishai on July 07, 2012, 10:01:08 pmI must agree with Mr. typo on this.  This is too easy to do with code to justify adding a new component.  Just use TEdit and the OnKeyPress and add whatever keys you want to allow. This is a very simplistic view of the problem. You do not take in to account validation (think about how many dots are allowed to be typed negative numbers ee don't accept the minus char anywhere except the 1st position) and the most difficult of all, alignment having a numeric edit that is aligned on the right and that can not be done with out creating a new component. ---------------------------------------------------------------------- Avishai · 2012-07-07 23:04 No it is not.'and the most difficult of all, alignment having a numeric edit that is aligned on the right ' taRightJustify + Plus  'in '-' in the OnKeydown. It takes some coding. But it is a simple coding task. You simply need to think it through an write the code.  It is not that complicated.  And it is not a problem.  The reason that it has not been implanted as a control is that is is so simple to do with code and TEdit.  Write it once correctly and you never have to do it again.