percent format is changing values

Hi,

I want to show percent (%) sign with the value in grid.
I am using GridControl,
set column cellValuetype=system.Decimal and apply "P" Format on the column.
the result is strange, if cellvalue is 7 the grid will show it to 700.00 %, and at the same time cellValue is 7.

if I change formatted text to 7.00 % the cellValue becomes .007

I simply want to add percent sign with my value and do not need to change the value. At the same time I dont want not change cellValueType to system.string as it will affect on sorting.

please help.
Regards
Touqeer Ahmed Ahson


4 Replies

AD Administrator Syncfusion Team November 19, 2007 04:19 PM UTC

One place you can change the text that is displayed in a cell without having to worry about affecting CellValue's or CellValueType's, etc. is to use the DrawCellDisplayText to do the formatting you want. Here is a little sample.



SyncScrolling_2.zip


TA Touqeer Ahmed Ahson November 20, 2007 06:05 AM UTC

thanks a lot. it is working without disturbing original cellvalues.
but there is another problem, as this % is not part of the cellvalue rather just a part of the displaytext so when i call the method of ResizeToFit on column only integer value is visible though % is append with string but it is not visible.

please see the attached solution, in the solution in col 4 the '%' is not visible because i applied resizeToFit on this column, however you can see it by increasing column's width. any solution??

Regards,
Touqeer Ahmed Ahson



SyncScrol.zip


AD Administrator Syncfusion Team November 20, 2007 11:43 AM UTC

The simplest thing to do is to just increase the colwidth a little after calling ResizeToFit.

this.gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Col(4));
this.gridControl1.ColWidths[4] += (int) (1 + gridControl1.ColStyles[4].Font.GdipFont.SizeInPoints);





TA Touqeer Ahmed Ahson November 21, 2007 05:38 AM UTC

it is working thanks again


Loader.
Up arrow icon