Hi, In a xamDataGrid, I am trying to restrict the entry of a numeric value in a cell to the length of 10. I am not doing this with ValueConstraint wherein it displays a message 'invalid data' but still allows user to enter more than 10 characters. Instead I want the user to restrict typing more than 10 characters. To do that I use the keydown event, and the following code:-
if (grdData.ActiveCell.Field.Name == "NumericCellName") { CellValuePresenter cvp = CellValuePresenter.FromCell(grdData.ActiveCell);
if (cvp != null) { if (cvp.Editor != null) { if (Convert.ToString(cvp.Editor.Value).Length > 10) { e.Handled = true; return; }
} } }
It works fine when the user key-in the data, say after 10th character keyed in, it does not allow 11th character to be keyed in. But when the whole text is selected in the cell, and when the user types something still it restricts input which is wrong, when the whole text is selected, and some value is typed, it should ideally erase the selected text and accept the new data keyed in.
Please advice what had to be done towards this.
Thanks.
Hi Peter
Thanks it worked
-Kiran
Hi Kiran,
Sorry I missed that out. Actually when applying such formatting in xaml you should set them like so:
Mask="{}{double:5.2}"
Please let me know if you encounter anything else.
Sincerely,
Petar Monov
Developer Support Engineer
Infragistics Bulgaria
www.infragistics.com/support
It is complaining about this line
<Setter Property="Mask" Value="{double:5.2}"/> .. I believe this functionality is supported in 2010.1 & CLR 3.5
Thanks
Hi,
The xaml snippet you provided seems ok. According to the error text I suggest you find this “5.2” tag on line 54. There might be a typing mistake you have overlooked.
Regards Petar.
I am using 2010.1 version and CLR 3.5. I tried the following
Created this style
<Style TargetType="{x:Type igEditors:XamNumericEditor}" x:Key
="NewStyle">
<Setter Property="Mask" Value="{double:5.2}"/>
</Style>
and attached to Grid Field
<
my:Field Name="Qty" Width="70">
Getting compilation error
Error 7 The tag '5.2' does not exist in XML namespace ''. Line 54 Position 33.
Pls let me know is this right..