Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
920
System.FormatExpression being thrown on empty formatted text
posted

Infragistics is throwing and catching a System.FormatExpression every time a cell/column has no data in a formatted cell.  Here's some code:

                              column.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Time;
                              column.Format = "hh:mm";
                              column.MaskInput = "hh:mm";
                              column.CellDisplayStyle = CellDisplayStyle.FormattedText;
                              column.MaxLength = 5;

 The problem is I have 6 columns that are being accessed and throwing exceptions during any event like clickcell or onmouseover.  This is slowing down the program.

Is there a way to fix this other than having to set all my values to some default acceptable values?

  • 920
    posted in reply to Mike Saltzman

     

     

    Figured out how to reproduce the issue.  Basically the grid System.FormatExceptions all over the place if you feed it empty strings on a Time column type

  • 920
    posted in reply to Brian Fallon

    the column is a string...

    hovering over and clicking #1 Time cell:

    makes this happen in the immediate window.

     

    first chance exception of type 'System.FormatException' occurred in mscorlib.dll

    A first chance exception of type 'System.FormatException' occurred in mscorlib.dll

    ...

    A first chance exception of type 'System.FormatException' occurred in mscorlib.dll

     

     

    I'm going to see if there's anywhere i can step through and see if I can't write up a small project that reproduces the error.

  • 69832
    Offline posted

    I don't think you are supposed to use the 'FormattedText' setting unless you have rich text in the cells, i.e., HTML-like values that format the content with bolding, coloring, etc. The term 'format' in that setting does not mean formatting in the same context as the Format property. You should probably just not set the CellDisplayStyle property.

    Wrong I was, the 'FormattedText' setting for CellDisplayStyle and the Format property are related.

  • 469350
    Offline posted

    Hi,

    It's hard to say without knowing what exactly is causing the exception. What's the DataType of the column?

    I doubt there's much you can do to avoid the exception on your end, other than what you suggested about providing a default value. But the grid should really avoid exceptions whenever possible, and if this is something that we can detect, we should fix this in the grid. Can you post a small sample project demonstrating the exception so we can check it out?