Hi,
I am setting the MinValue and MaxValue for a cell in a grid with the help of BeforeCellActivate event.
However MaxValue is set correctly but MinValue is NOT set.
Eg: I have MaxValue as 1000 and MinValue as 10.
It is not allowing me to enter values more than 1000 which is correct but for MinValue it is allowing me to enter 9,8,7 etc.. till 0. The datatype of the column is Integer. Any workarounds?
Regards,
Viswanth V.G
Hi Viswanth,
When you say you can enter a value of 9, do you mean the user can type the number 9? Or so you mean they can type a 9 and then leave the cell with no error?
The grid has to allow the user to type in a single digit, because it doesn't have any way of knowing that they are not going to type any more digits. You have to be able to type "9" in order to type "90", for example. So the validation for MinValue in this case cannot occur until the user is done typing and tries to leave the cell.
Also, I wasn't aware that there is a MinValue or MaxValue on the cell, I though these prpoerties were on the column. Is that what you meant?
Mike,
Yeah! Got your point. I have set MinValue as 0 and MaxValue is 9, means, user cannot enter 10 (basically 2 digits) and the minimum value is 0 (baiscally non-negative). My actual problem was i have to set this to cells rather than columns. That is the reason why i was not able to validate.
Mike, is there any workaround to set the mask for a cell or a ultramaskeditor in a grid cell? I have a column called "Field" and each row would have different datatypes, one is double and other is int and date so on...If i change the datatype entire column is reset and date entered is converted to int and my head starts spinning..
Thanks,
You can apply a different mask on each cell using editors. What you would do is set the column's UseEditorMaskSettings property to true. Then you assign an Editor or EditorControl to the column that has the masking you want. For example, you could use the UltraMaskedEditor control or the UtraNumericEditor.
The InitializeRow event is usually a good place to do this.
I'm not sure if this applies to the MinValue or MaxValue, though. Those are not part of the mask, so I don't know if the grid picks those up from the editor.
The problem is, i have a data driven UI and i have the datatypes coming from db. So based on the datatypes i would set the column style, the caveat's are:
1. My column name is Field and is the same for all, means only the cell's datatype has to differ and not columns' datatype.
2. I cannot set the InputMask as it applies for a column and all the entered values get reformatted as specified in the mask.
3. I cannot set the MaskInput anywhere in the grid event as it re-sets the previous style..
Have implemented a cumbersome logic which is working fine, but for double datatypes is there a way to increase the decimal values to 5 instead of the default 2. What it does is, it doesn't allow me to enter more than 2 decimals where as my min value is sometimes 0.00001. It allows only xxxx.00.
Need help..
I don't understand. Are you saying that you are setting the editor of a cell in one row and it's affecting the cells in the other rows? I don't see how that's possible.
It sounds to me like you are still setting the mask or editor properties of the column and not the cell.
I tried that prior to my post and unfortunately since my grid is created at runtime i have same column name. My grid looks like this..
DataElement <some columns hidden> Value(user would enter)
Name: Mike
DoB: 06/02/1970
Salary: $10000.50
Now, if i use a mask (double) for salary, DoB value is getting rearranged as 06.02 (it applies to all the fields as the column name is NOT unique).
Hope i'm clear this time. Any suggestions?
Thanks Mike.
Maybe I wasn't clear in my previous post. I was explaining how you apply a different mask to each cell. Not to the column.
That was what you asked and that was what my answer explained how to do.
You have to use an editor for that. You don't set the mask on the grid column. You set it on the editor. Then you apply the editor to the cell.