FarPoint Forums

The FarPoint Message Boards
Welcome to FarPoint Forums Sign in | Join | Help
in Search

Number format - should not show leading zero

Last post 05-15-2008, 3:38 PM by saritha_v. 7 replies.
Sort Posts: Previous Next
  •  05-08-2008, 5:47 PM 63219

    Number format - should not show leading zero

    Hi,

     I'm trying to assign a format of "###.0" to a column. So, if I pass the value "1", it should appear as "1.0", and ".5" as ".5"). I don't want .5 appearing as 0.5, which is what seems to be happening. I'm using a generalcelltype, and assigning "###.0" to formatstring. Please advise. Btw, I couldn't get this by using a numbercelltype either

    Thanks!

  •  05-09-2008, 6:40 AM 63231 in reply to 63219

    Re: Number format - should not show leading zero

    Given the format that you have it would always display the 0.5.  You should be able to get the results you want by using a NumberCellType and setting the DecimalPlaces to 1 and the LeadingZero to false.

    Bob M.
    FarPoint Technologies, Inc.
  •  05-09-2008, 10:53 AM 63253 in reply to 63231

    Re: Number format - should not show leading zero

    I already tried that.

    n.LeadingZero = LeadingZero.No

    n.DecimalPlaces = 1

    This shows me "1" and "0.5", instead of "1.0", and ".5"

  •  05-09-2008, 11:05 AM 63254 in reply to 63253

    Re: Number format - should not show leading zero

    Attachment: leadingzero.JPG
    What version are you using?  In my test using the following code it is working correctly (see attachment)...

    Dim num As New FarPoint.Win.Spread.CellType.NumberCellType
    num.LeadingZero = FarPoint.Win.Spread.CellType.LeadingZero.No
    num.DecimalPlaces = 1

    FpSpread1.ActiveSheet.Cells(0, 0, 2, 2).CellType = num

    FpSpread1.ActiveSheet.Cells(0, 0).Value = 1
    FpSpread1.ActiveSheet.Cells(2, 0).Value = 0.5

    Bob M.
    FarPoint Technologies, Inc.
  •  05-09-2008, 11:14 AM 63257 in reply to 63254

    Re: Number format - should not show leading zero

    Oh, I was assigning it to the Text property of the cell. I changed it to Value, and it works as it should.

    Thanks!

  •  05-15-2008, 3:02 PM 63551 in reply to 63254

    Re: Number format - should not show leading zero

    Hi,

      a related question. I'm asigning the horizontal alignment of the cell to "Right" but it comes up left-aligned. Am I missing something?

    n.LeadingZero = LeadingZero.No

    n.DecimalPlaces = 1

    acell.CellType = n

    acell.HorizontalAlignment = CellHorizontalAlignment.Right

    acell.Value = sValue

     

    Thanks..

  •  05-15-2008, 3:10 PM 63552 in reply to 63551

    Re: Number format - should not show leading zero

    It should be right-aligned by default.  There must be some code somewhere overriding your default setting.

    Bob M.
    FarPoint Technologies, Inc.
  •  05-15-2008, 3:38 PM 63556 in reply to 63552

    Re: Number format - should not show leading zero

    Yes, found the line where this was happening. Fixed it. Thanks!
View as RSS news feed in XML
     FarPoint Forums Home