Jump to content


Photo

NxNumberColumn Input


  • Please log in to reply
20 replies to this topic

#1 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 02 July 2007 - 02:04 PM

Hi Boki

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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 02 July 2007 - 02:16 PM

Hello Deon,

Hm, I have test it now and it work fine.

Maybe you have set eoAllowFloat in EditOptions of Column to False?

Best regards
boki@bergsoft.net | LinkedIn Profile
--
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 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 02 July 2007 - 02:50 PM

Hi Boki

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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 02 July 2007 - 05:20 PM

Hello Deon,

I understand now. I will try to do something. I will be back here soon.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 02 July 2007 - 06:23 PM

Hello Deon,

You may comment line:

CODE
Precision := Self.Precision;


inside

CODE
procedure TNxNumberColumn.UpdateEdit;


(file NxColumnClasses.pas)

but I will need to do some more testings, to see if this is ok.

regards
boki@bergsoft.net | LinkedIn Profile
--
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 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 02 July 2007 - 08:02 PM

Thanks Boki.

I will try it and let you know.

Regards,
Deon

#7 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 02 July 2007 - 08:02 PM

Hello Deon,

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
boki@bergsoft.net | LinkedIn Profile
--
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 02 July 2007 - 08:09 PM

PS. Maybe in your case something may be done with using OnApplyEditText event?

Best regards
boki@bergsoft.net | LinkedIn Profile
--
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 02 July 2007 - 08:47 PM

Hello Deon,

Maybe next solution is better:

Inside EditCell procedure (NxCustomGridControl.pas), change:

CODE
Columns[ACol].UpdateEdit;


into

CODE
if AText = '' then Columns[ACol].UpdateEdit;


In that case, UpdateEdit will not be called after editing with typing key.

Please tell me what you think.

regards
boki@bergsoft.net | LinkedIn Profile
--
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 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 02 July 2007 - 08:49 PM

Hi Boki

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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 02 July 2007 - 08:52 PM

Hello Deon,

Please look at post I have add before you post this one.

Maybe this can be solution.

regards
boki@bergsoft.net | LinkedIn Profile
--
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 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 02 July 2007 - 08:54 PM

Thanks. I'll try it now.

#13 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 02 July 2007 - 09:02 PM

Ok. That seems to work fine.

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 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 03 July 2007 - 11:22 AM

Hi Boki

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:

CODE
  if Value = DecimalSeparator then
    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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 03 July 2007 - 11:44 AM

Hello Deon,

Please try next:

In NxColumnClasses.pas replace next procedure:

CODE
function TNxCustomNumberColumn.IsKeyValid(Key: Char): Boolean;
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 smile.gif

PS. Is there any way to better write this code smile.gif
boki@bergsoft.net | LinkedIn Profile
--
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 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 03 July 2007 - 12:33 PM

Now I have the following:

In EditCell:
CODE
if AText = '' then
  Columns[ACol].UpdateEdit;


and

CODE
function TNxCustomNumberColumn.IsKeyValid(Key: Char): Boolean;
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 03 July 2007 - 12:46 PM

Hello Deon,

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
boki@bergsoft.net | LinkedIn Profile
--
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 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 03 July 2007 - 12:48 PM

PS.

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 smile.gif
3) With fixing bug 1) , this will be done too.
boki@bergsoft.net | LinkedIn Profile
--
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 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 03 July 2007 - 01:08 PM

OK. I will wait for the next (pre?) release before I test it again smile.gif

Thanks
Deon

#20 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 03 July 2007 - 01:13 PM

Hello Deon,

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
boki@bergsoft.net | LinkedIn Profile
--
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