Bug ? LeadingZero Property in Form v4 vs2008

Posted by: romensfzl-fp on 8 September 2017, 1:05 pm EST

  • Posted 8 September 2017, 1:05 pm EST

    I find a bug in v4,sample code:


    New a windows application,drop a spread and a button to a form.


    write code in button_click


    {


    Farpoint.Win.Spread.CellType.NumberCellType cellType = new Farpoint.Win.Spread.CellType.NumberCellType();


    cellType.DecimalPlaces = 0;


    cellType.LeadingZero = FarPoint.Win.Spread.CellType.LeadingZero.No;


    this.fpSpread1_Sheet1.Columns[0].CellType = cellType;


    }


    Execute this progame.


    Pless button1


    input value in 0 Column ,tip a error!


     


     


     

  • Replied 8 September 2017, 1:05 pm EST

    I am not receiving any type of error doing this and the cell does not display the leading zero.
  • Replied 8 September 2017, 1:05 pm EST

    Hello,


    I was able to reproduce this exception and have reported this as a bug (#22163) for the development team to fix for the next maintenance release. However, I am curious, what are you expecting to see in the cell when you do this?

  • Replied 8 September 2017, 1:05 pm EST

    For example:


    A grid like this:


    --     26     38     39     40     41       42     43     44     45


    --     29     30     31     32     33       34     36


    --      S      M       L     XL   XXL   3XL


    Above is rowHeader


       0    0    100    100      0      0        0        0      0     0


       0  2500    0        0      0     45       0        0      0     0


       0     0       0        0      0      0       12       0      0     0


    Above is datavalue


    datavalue seeing is poor


    next show is good


                    100    100                                             


           2500                            45      


                                                           12 


     

  • Replied 8 September 2017, 1:05 pm EST

    Use spwin4_net35-3503 ,this bug resolved!


    In V3 version, 


    cellType.LeadingZero = FarPoint.Win.Spread.CellType.LeadingZero.No;


    if cell's value is 0 then show space.


    if cell's value is 0.12 then show .12


    But in spwin4_net35-3503


    if cell's value is 0 then show 0


    if cell's value is 0.12 then show .12


    I hope if cell's value is 0 then show space.


    I create a custom celltype,and override the PaintCell method.


            public override void PaintCell(System.Drawing.Graphics g, System.Drawing.Rectangle r, FarPoint.Win.Spread.Appearance appearance, object value, bool isSelected, bool isLocked, float zoomFactor)
            {


                if (value != null && value.ToString() == "0")
                {
                    FarPoint.Win.Spread.Appearance newApp = appearance;
                    newApp.ForeColor = System.Drawing.Color.White;
                    newApp.BackColor = System.Drawing.Color.White;
                    base.PaintCell(g, r, newApp, value, isSelected, isLocked, zoomFactor);
                }
                else
                {
                    FarPoint.Win.Spread.Appearance newApp = appearance;
                    newApp.ForeColor = System.Drawing.Color.Black;
                    newApp.BackColor = System.Drawing.Color.White;
                    base.PaintCell(g, r, newApp, value, isSelected, isLocked, zoomFactor);
                }


            }


    When I change cell value ,it work ok!


    But i bind database data to grid, 0 show 0,not space.


    Pealse help me.


     



     


     

  • Replied 8 September 2017, 1:05 pm EST

    Make sure you are setting your cell type in the cell after you are done with your binding or set DataAutoCellTypes to False and assign your cell type to the cells.
  • Replied 8 September 2017, 1:05 pm EST

    CellType set is right. When i change cell value from 0 to 1,then from 1 to 0,leave cell,0 show space. If i not change,0 is 0.

  • Replied 8 September 2017, 1:05 pm EST

    Hello,


    The code you posted above is always painting the value object in the cell (by calling the base class). I do not see where you are changing the object in value from 0 to space. I would suggest stepping through the code in the PaintCell method to see what is different the first time through versus after changing the value in the cell.

  • Replied 8 September 2017, 1:05 pm EST

    scotts ,Problem  resolved. Thanks!
  • Replied 8 September 2017, 1:05 pm EST

    Hello,


    The best way to implement this is to create a custom celltype and override the PaintCell method to paint a null value in the cell if the value is 0.


    If the user may be typing in these 0's, then you need to leave the LeadingZero property turned on. Since you have no decimal places, there is no need to set this property.

Need extra support?

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

Learn More

Forum Channels