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
4695
format in the cell
posted

Dear all,

I have set below code but find that user can input more than two decimal places. Do you know why? How to solve??

 

private

 

 

 

void dtgSupplier_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs

e)

{

e.Layout.Bands[0].Columns[

 

 

"LAST_PURCHASE_COST"].MaskInput = "nnnnnnnnn.nn"

;

  • 469350
    Offline posted

    I tried this out and I am unable to enter more than 2 decimal places in the cell.

    What is the DataType of the column? This is a numeric mask and so it will not work unless the DataType of the column is numeric. I don't think it will work if the column is a string, for example.

    If that does not help, then are you seeing the masking prompt in the cell at all? Perhaps some code that runs after this is clearing the mask?

  • 455
    posted

    Hi,

    I don't know if it is possible to validatie on realtime within the cell.

    One thing you could do is set the Format property of the column so that it only shows 2 decimal values. In this case the user can still type in multiple decimal values but only 2 will be shown.

    Before saving the value to the database for example it could also be rounded.

    If you don't want the user to be able to fill in more than 2 decimal places at all you could validate in the BeforeCellUpdate event and give the user a message or something other than that if the value is not correct.

    Hope this helps!