You are not logged in.
This forum has been archived and no longer accepts new user registrations. Please report your questions, problems, and feedback to the issue page of ReoGrid on GitHub. Thank you for your cooperation.
Pages: 1
Topic closed
Hello Jing,
Is there anyway to have number with x decimal places and not have show the trailing zeros? If not maybe you can add property that does removes the trailing zeros.
I know the way you have this, is the way excel does their decimal place holders, when there is no number they put zeros for the place holder. I know i can in code dynamically change the decimal place holder in code to reflect the something i am asking you.
Shane
Last edited by asparatu (2016-03-29 03:44:58)
Offline
Hi Shane, I think that means that you don't want to use data formatter to display numbers. I think you can:
1. Set the cell data format to Text
2. Convert your number to string, using like number.ToString(), and set the text into cell
If you want text aligned to right, set the cell style HAlign to Right.
Here is the code (VB.NET):
Dim sheet = grid.CurrentWorksheet
Dim cell = sheet.Cells("A1")
cell.DataFormat = unvell.ReoGrid.DataFormat.CellDataFormatFlag.Text
cell.Data = 1.23456789.ToString()
cell.Style.HAlign = unvell.ReoGrid.ReoGridHorAlign.Right
Last edited by Jingwood (2016-03-29 15:26:02)
Offline
Hello Jing,
No.. I want to use the number dataformat and still input 9 decimal place. example: inputted text would be 1.2345, but the number formatter would change it to this, 1.23450000. what i want to know is can input the original input and not have number formatter automatically put the trailing zeros. That is why i was saying i can make check in cell data event maybe if the number has trailing zeros change it, i know see problem with that.. if they when to change the value to have more precises number they can not.. or can make when they press input any text it will automatically reset the input decimals back to 9
I really do not want have as text then i will have check to make sure the value is number or not and checks if there is more then one period, but if do do that. I can just make as function in dll.
I can do it cellinputchar event.
Shane
Offline
You want when input 1.23 then the cell display result is 1.23, when input 1.23456 the cell display result is 1.23456. So this means you can't use number data format, instead use Text will achieve your requirement.
Data Format On = Change data display result
Data Format Off = Keep original data
Your goal is 'Keep original data'.
In my previous reply I gave you wrong code, when the data set into cell it doesn't need to be converted into string. Just put number into cell.
Dim cell = sheet.Cells("A1")
cell.DataFormat = unvell.ReoGrid.DataFormat.CellDataFormatFlag.Text
cell.Data = 1.2345678
cell.Style.HAlign = unvell.ReoGrid.ReoGridHorAlign.Right
Anytime you can get back the number data from cell.
Dim mynumber As Double = sheet("A1")
MsgBox(mynumber.GetType().Name) 'result is Double
Last edited by Jingwood (2016-03-31 01:43:32)
Offline
Pages: 1
Topic closed