This is a migrated thread and some comments may be shown as answers.

Format a decimal cell so that numbers are aligned to decimal point

2 Answers 331 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andrea
Top achievements
Rank 1
Andrea asked on 04 Mar 2013, 11:49 AM
Hello,

I was requested to port an access 2002 data centric application to winforms .net 4.0 .

Users do not like the way I'm showing decimal numbers, they do not want to see not significative zeroes and they want numbers to be aligned to decimal separator, not to right margin. What they want is what you can see in accatched picture (old microsoft access program).

It is possible to obtain such output, perhaps I have to manually draw the cells? If I have to draw the cell, how can I apply the same formatting to cell editor?

Many Thanks


2 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Petrov
Telerik team
answered on 05 Mar 2013, 02:48 PM
Hello Andrea,

Thank you for writing.

You can use the CellPaint event of RadGridView to draw the text of the cells yourself. You can also specify a format string for the decimal column which would show the data in the format you want, without insignificant digits. You can set the TextAlignment of the grid spin editor to Center, but you will no be able to align it according to the decimal separator. I have attached an example project where I have implemented all of the above.

I hope this will be useful. Should you have further questions, I would be glad to help.

All the best,
Ivan Petrov
the Telerik team
WinForms Q1 2013 boasts PivotGrid, PDF Viewer, Chart enhancements and more. Join us for a FREE webinar to see all the new stuff in action.

Interested, but can’t attend? Register anyway and we’ll send you the recording.
0
Andrea
Top achievements
Rank 1
answered on 05 Mar 2013, 03:38 PM
Thank you for using your time to produce this sample project, good to know that I can paint on cells using custom code.

All the best.
Andrea



Tags
GridView
Asked by
Andrea
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Andrea
Top achievements
Rank 1
Share this question
or