i'd conditionally change formatstring property of grid's column.
the input double.
what want following :
if (cellvalue % 1 == 0) acolumn.displayformat.formatstring = "n0"; else acolumn.displayformat.formatstring = "n2";
is there way @ runtime without having check each value of column ?
any appreciated, !
you can use approach witn handling columnview.customcolumndisplaytext event demonstrated @kenrogers.
or can use custom formatting feature column:
acolumn.displayformat.formattype = devexpress.utils.formattype.custom; acolumn.displayformat.format = new customdoubleformatter(); public class customdoubleformatter : iformatprovider, icustomformatter { public object getformat(type format) { return this; } public string format(string format, object arg, iformatprovider provider) { bool hasfractionalpart = ((double)arg % 1.0 > double.epsilon); return string.format(hasfractionalpart ? "{0:n2}" : "{0:n0}", arg); } }
p.s. more detail formatting cell values refer formatting cell values article.
Comments
Post a Comment