Flexgrid null problems

Posted by: p4spares on 25 November 2019, 4:13 am EST

    • Post Options:
    • Link

    Posted 25 November 2019, 4:13 am EST

    hi,

    i’m converting my application from the old flexgrid 4.0.20162.188 to the latest 4.0.20193.393 and i’m facing a problem : the ToString() of my cell-object is automatically turned to null.

    i found some workarounds but i dont understand if it’s a bug or i’m missing something.

    here is my code, reduce to the minimum:

    c1FlexGrid1.EmptyAsNull = false;
    c1FlexGrid1.Cols[2].Caption = "Ula";
    c1FlexGrid1.Cols[2].DataType = typeof(WeightEditorValue); // see workaround #1
    c1FlexGrid1.Rows[1][2] = new WeightEditorValue();
    if (c1FlexGrid1.Rows[1][2] == null)
        MessageBox.Show("is null!");
    
    

    here is the data class:

    public class WeightEditorValue
        {
            public override string ToString()
            {
                return "";
                //return " "; see workaround #2..
            }
        }
    
    

    if i run this code, i get the message box.c1FlexGrid1.Rows[1][2] is null.

    if in the ToString() i return “”, it works as i expect.

    if i comment the line c1FlexGrid1.Cols[2].DataType = typeof(WeightEditorValue) it workes as expected.

    EmptyAsNull… seems have no effect, at least in this case.

    anybody can help me to understand what’s the best way to get the previous behaviour?

    thanks,

    David

  • Posted 27 November 2019, 1:23 am EST

    Hello,

    We are discussing the case with the developers, will get back to you very soon.

    [Internal Tracking Id : 408439]

    Regards,

    Prabhat Sharma.

  • Posted 27 November 2019, 5:30 am EST

    I had a similar discussion with support - apparently this was changed intentionally in version 4.0.20163.212 - more details in my support issue 220974.

    Best regards

    Wolfgang

  • Posted 28 November 2019, 4:09 am EST

    Hello,

    @Wolfgang, thank you the help.

    @David, as said by the @Wolfgang this behavior was changed intentionally in version later to 4.0.20162.188 because there was a issue with deleting unbound cell content and the cause is entering empty.String value to non-nullable type and try to convert it which is later fixed as convert empty.String to null for all types.

    So it is a default behavior for current build and you can use your workaround by return the blank space as given below :

    public class WeightEditorValue
    {
       public override string ToString()
         {
                return " "
         }
    }
    

    I hope it clears.

    Regards,

    Prabhat Sharma.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels