NxNumberColumn Input
#1
Posted 02 July 2007 - 02:04 PM
I am having a small problem with the way that the NxNumberColumn handles the input of decimals. If you don't specify the leading zero when entering a decimal (float), the number is entered as a "whole" number.
For example:
If you enter 0.5 the value is 0.5
If you just enter .5 (without the leading zero) the value is 5
Would it be possible to get the NumberColumn to recognize the value as a decimal wihtout having to enter the leading zero?
Thanks
Deon
#2
Posted 02 July 2007 - 02:16 PM
Hm, I have test it now and it work fine.
Maybe you have set eoAllowFloat in EditOptions of Column to False?
Best regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#3
Posted 02 July 2007 - 02:50 PM
Make sure the cell is not in edit state when you start typing. The cell must just be selected (blue) and then type a "." on your keyboard. You will see the cell goes into edit state with a zero, but the "." that you typed is not there (there is no decimal separator).
If you then type 5 the value is 05 (it should be 0.5)
Regards,
Deon
#4
Posted 02 July 2007 - 05:20 PM
I understand now. I will try to do something. I will be back here soon.
Best regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#5
Posted 02 July 2007 - 06:23 PM
You may comment line:
inside
(file NxColumnClasses.pas)
but I will need to do some more testings, to see if this is ok.
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#6
Posted 02 July 2007 - 08:02 PM
I will try it and let you know.
Regards,
Deon
#7
Posted 02 July 2007 - 08:02 PM
Hm, maybe is better to leave this line untouched.
When user start editing cell (click on cell, or start typing), text from cell is transfered into Inplace Edit.
Then, after setting Precision, text inside Inplace Editor is formated again.
Best regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#8
Posted 02 July 2007 - 08:09 PM
Best regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#9
Posted 02 July 2007 - 08:47 PM
Maybe next solution is better:
Inside EditCell procedure (NxCustomGridControl.pas), change:
into
In that case, UpdateEdit will not be called after editing with typing key.
Please tell me what you think.
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#10
Posted 02 July 2007 - 08:49 PM
I tried it whithout that line, and then it seems to work fine (but maybe it breaks something else?). I have put the line back again, as you suggested.
PS: The problem is not just with decimals. You get the same problem if you try to start typing a negative number (in other words if the first key you press is the minus sign). Maybe the problem is that the SetValueToText procedure can only take a Double as the SendValue paramater, and not "." or "-"
(I don't know - I'm just guessing)
I will try to do something with OnApplyEditText.
Regards,
Deon
#11
Posted 02 July 2007 - 08:52 PM
Please look at post I have add before you post this one.
Maybe this can be solution.
regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#12
Posted 02 July 2007 - 08:54 PM
#13
Posted 02 July 2007 - 09:02 PM
Decimals are now entered correctly, and negative numbers can now also be entered by typing the minus sign. The precision is also still handled correctly when the cell loses focus.
I will test it some more when I get time.
Thanks again,
Deon
#14
Posted 03 July 2007 - 11:22 AM
The latest fix still causes problems in other routines.
Now if I enter a negative number (example -5) and exit the cell, the value is still -5 even if AllowSigns is false.
I have tried putting the following into the grid's OnEdit event:
Value := '0' + DecimalSeparator;
This doesn't work either because OnEdit is called twice if you press "." or "-" to start cell editing. The first time the Value is changed to "0." by my code, but then OnEdit is called again with the value already set to 0 (which overrides my code).
If you start cell editing by typing a number, OnEdit is called only once. It looks like there is a routine somewhere that checks for "valid characters", and if the value is "." or "-" it changes the value to "0" and calls OnEdit again.
Any ideas?
Deon
#15
Posted 03 July 2007 - 11:44 AM
Please try next:
In NxColumnClasses.pas replace next procedure:
begin
Result := True;
if Key in ['1'..'9', '0'] then Exit;
if (eoAllowSigns in FEditOptions) and (Key in ['-', '+']) then Exit;
if (eoAllowFloat in FEditOptions) and (Key = DecimalSeparator) then Exit;
Result := False;
end;
I hope that now works
PS. Is there any way to better write this code
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#16
Posted 03 July 2007 - 12:33 PM
In EditCell:
Columns[ACol].UpdateEdit;
and
begin
Result := True;
if Key in ['1'..'9', '0'] then Exit;
if (eoAllowSigns in FEditOptions) and (Key in ['-', '+']) then Exit;
if (eoAllowFloat in FEditOptions) and (Key = DecimalSeparator) then Exit;
Result := False;
end;
This now seems to work fine if you want to start cell editing using "." or "-"
BUT:
Now I am noticing other strange behaviour, but I don't think it's related to these changes (It does the same thing on the original code before I made the changes).
1. I can't get the precision to work properly. I set the precision to 2 and then enter 2.2323232 and press <Enter>. The cell still shows 2.2323232. If I edit the cell again the cell text shows 2.23.
2. With Precision = 2, if the cell is not in edit state and I start typing 2.232323, I get 2.00232323. The cell formatting automatically inserts the .00 right after I type the first "2".
3. I set AllowSigns to True and enter -5. If I press <Enter> the cell shows -5. If I now click on the cell again to edit the value, the cell shows 0. The formatting is using the Min property to re-format the cell contents, but only on the second time the cell is edited.
#17
Posted 03 July 2007 - 12:46 PM
Please read for answers bellow:
1) I will work on it (worked on it and yesterday, but I need some small tweaks more). I will need to apply precision once more before text from InplaceEditor is transfered into Cell.
2) For me now work fine. Please contact me via e-mail to I send you latest release.
3) This is correct behaviour, but maybe I need to do something with Min property, for example a property to ignore Min property when it is 0.
Best regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#18
Posted 03 July 2007 - 12:48 PM
1) I can call KillFocus for Inplace Edit before text from Inplace Edit is transfered into cell, but maybe there can be more elegant solution
3) With fixing bug 1) , this will be done too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#19
Posted 03 July 2007 - 01:08 PM
Thanks
Deon
#20
Posted 03 July 2007 - 01:13 PM
If you want, I may send you latest release on your e-mail.
I will also re-upload files on users area durring today.
Best regards
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users