Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2334
Display and Edit percents
posted
I have a column that is type decimal and the value represents a percent. I store the values as decimal values (.02 instead of 2). If I set the FormatString of the column to "p2" the grid displays the value as a percent (2%). Is there a mask that I can apply that will treat the data entry as a percent and not a decimal value? i.e. the user enters 2 but the cell.Value is really .02.

I accomplish this in UltraNumericEditor by using a DataFilter where I multiply by 100 in OwnerToEditor and divide by 100 in EditorToOwner. I would like to treat grids and editors the same. Using datafilters in grids is a real hassle because it has to be assigned to the editor which I believe is shared and do not know how this would work. It would be nice if DataFilter was on Column but I'm sure there is a good reason it is not.

Is this possible by using a format and a mask instead of a DataFilter?

Thanks,
Drew
  • 469350
    Offline posted

    The editors created by the grid by default are shared. So doing something like this is usually not a good idea: 

    column.Editor.DataFilter = myDataFilter

    The way to do this so that it only affects the columns you want is to assign the editor or EditorControl of the column. 

    column.EditorControl = ultraNumericEditor1

    In this example, ultraNumericEditor1 is an UltraNumericEditor control with a DataFilter assigned to it.