User (Old forums)MemberSeptember 3, 2006 at 7:46 pmPost count: 23064
We are currently evaluating the Xceed Grid and it seems to the component satisfies our needs. We are currently working on an application which displays results of a query in a Grid. Also there are several property grids (based on Xceed Grid), which make enable to set the Result Grid’s properties, for example colors, formatting, grouping, and so on…
The question is that if a cell contains numerical value how to format it?
For example the following data is coming from the DB:
I want to round every cell value, somehow like this: #,##0.0 – where the result would be:
Where #,##0.0 is the format string which contains information about the number of decimal places, the thousand separator, and so on. If I set the format string based on the manual, the values are never rounded, so for example 3.1415 never will be 3.1 (in the case of 1 decimal place), the values are not rounded.
I browsed the Help, but unfortunately I couldn’t figured out how to round the values. Alternatively I could create a new CellViewerManager to display the rounded values correctly, but I don’t want to go this way, if there is another easier way to achieve this.
Is there any way to do this ?
Imported from legacy forums. Posted by Szabolcs (had 3581 views)User (Old forums)MemberSeptember 3, 2006 at 8:02 pmPost count: 23064
I tried to use the WinNumericTextBox control, but still no success to format:
WinNumericTextBox w = new WinNumericTextBox(false);
w.BorderStyle = EnhancedBorderStyle.None;
w.DataType = typeof(System.Decimal);
w.Decimals = 1;
c.CellViewerManager = new Xceed.Grid.Viewers.NumericViewer(w);
For example: 1092.75 will be after that I changed the CellViewerManager 1092.75.
If I change the datatype to Int32, then the decimal would disappear – this is correct.
If I change the datatype to Double, then nothing changed.
If I could make the w.Decimals to work, then the problem could be solved!
Imported from legacy forums. Posted by Szabolcs (had 487 views)User (Old forums)MemberSeptember 5, 2006 at 3:01 pmPost count: 23064
I’m not totally sure I understand if you want rounding or not, but if you do not want to use the CellEditor/ViewerManager, you can use the FormatSpecifier property on the cell to set it :
dataRowTemplate1.Cells[ index ].FormatSpecifier = “#,##0.0 “;
Imported from legacy forums. Posted by André (had 334 views)
- You must be logged in to reply to this topic.