We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

PositiveInfinity and NegativeInfinity as strings in DoubleTextBox

Hello. 

I'm using a GridNumericColumn which according to the online documentation uses a DoubleTextBox as value editor.
Is there a way to enter the double value PositiveInfinity (System.Double.PositiveInfinity) or NegativeInfinity (System.Double.NegativeInfinity) as a string in this field?
When populating the grid, the infinity values from database are shown in the grid as "79228162514264300000000000000.00". When the grid is scanned in backend, these values are read as infinity (System.Double.IsPositiveInfinity is true). However, if I enter edit mode and commit changes without actually modifying the value, in the cell these cells are no longer "infinity" when I test them in backend with System.Double.IsPositiveInfinity but instead, the same entered number which is 7.92281625142643E+28 is read.
Is there a way to allow entering the strings "Infinity" and "-Infinity" in the field? Maybe the solution is to just use a GridTextColumn in combination with an IValueConverter, but I'm just asking in case DoubleTextBox was already taking this in account with some option I'm missing.

Thanks in advance!

Fernando

5 Replies

AS Ayyanar Sasi Kumar Jeyaraj Syncfusion Team December 28, 2015 02:15 PM UTC

Hi Fernando,

When you are binding maximum infinity value, the value is not displayed in view and its correctly displayed in edit mode. Is this the issue you are referring? Refer the below sample where we tried to reproduced this issue.

Sample: https://www.syncfusion.com/downloads/support/forum/121536/ze/Numeric_textbox_in_wpf1708064484

Could please confirm the issue to provide the fix?

Regards
Ayyanar


CF Carlos Fernando Consigli December 28, 2015 04:28 PM UTC

Hi Ayyanar. Thanks for your quick answer.
I was referring to both the inability to enter (and read) the value (-/+)Infinity in the field as "Infinity" instead as a number, and the fact that if you only enter edit mode and commit changes, the value is no longer read as Infinity in the model.

Everything reduces to the fact that there is no way to enter the value Infinity in the fields that don't have Infinity as an initial value.  You can enter the number 79228162514264300000000000000.00 which is the one shown for initial "Infinities", and it will persist it in the model as 7.92281625142643E+28. In fact, in my opinion this last behaviour is correct because Infinity should be just "Infinity" and not be mapped to any natural number, and it is ok to persist 79228162514264300000000000000.00 as a number. I think the solution may be to show the string "Infinity" for infinity values, and to allow the user to enter the word "Infinity" (or -Infinity) in the field.
Of course, I understand that this may be a sort of a hard and breaking change, because of the "masked" nature of this control and because as it currently only takes numbers and decimal separators as inputs, it should necessarily start accepting characters to allow "Infinity" with all what that implies (validating for invalid strings, etc).

Fernando


SR Sivakumar R Syncfusion Team December 29, 2015 03:31 PM UTC

Hi Fernando,

We have analyzed and your requirement to display infinity in GridNumericColumn can’t be achieved. But you can use GridTextColumn to display as you required. You can validate the editing by CurrentCellValidating event.

this.datagrid.CurrentCellValidating += Datagrid_CurrentCellValidating;

private void Datagrid_CurrentCellValidating(object sender, CurrentCellValidatingEventArgs args)

{

    if (args.Column.MappingName != "salary")

        return;


    double d;

    if(args.NewValue == null || !double.TryParse(args.NewValue.ToString(), out d))

    {

        args.ErrorMessage = "Enter valid double value";

        args.IsValid = false;

    }
}


Sample:
https://www.syncfusion.com/downloads/support/forum/121536/ze/Sample217465157



Please let us know if you have any questions.

Thanks,
Sivakumar


CF Carlos Fernando Consigli December 30, 2015 04:26 PM UTC

Perfect, thanks, I implemented that solution and it's working ok. Also, that way was not necessary to deal with the IValueConverter.
Thanks, I really appreciate you took time to help me.
Greetings,

Fernando


AS Ayyanar Sasi Kumar Jeyaraj Syncfusion Team December 31, 2015 01:05 PM UTC

Hi Fernando,
Thanks for the update.
Please let us know if you have any further assistance.
 
Regards
Ayyanar

Loader.
Up arrow icon