My fields are created like this (minus a few settings that I have removed for simplicity):Field field = new Field();field.Name = fieldName;field.Label = label;field.Settings.EditorType = typeof(XamTextEditor);dataGrid.FieldLayouts[0].Fields.Add(field);
How would I add the following ValueConstraint to this field?ValueConstraint vc = new ValueConstraint();vc.MinLength = 0;vc.MaxLength = 2;
Thank you,Mike
Hello Mike,
Let's say you want a required field (min 0 chars) and maximum of 100. All you need to do is set the XamTextEditor Value Constraint Property like this
<igEditors:XamTextEditor.ValueConstraint > <igEditors:ValueConstraint MinLength="0" MaxLength="100"/></igEditors:XamTextEditor.ValueConstraint>
and, of course, choose the desired way to display the error by modifying the XamTextEditor InvalidValueBehavior Property like this:
<igEditors:XamTextEditor InvalidValueBehavior="DisplayErrorMessage" Name="xamTextEditor" ValueType="{x:Type sys:String}" Width="116"> <igEditors:XamTextEditor.ValueConstraint > <igEditors:ValueConstraint MinLength="0" MaxLength="100"/> </igEditors:XamTextEditor.ValueConstraint> </igEditors:XamTextEditor>
More on this topic -- http://help.infragistics.com/Help/NetAdvantage/WPF/2008.2/CLR3.X/html%5CInfragistics3.Wpf.Editors.v8.2~Infragistics.Windows.Editors.ValueEditor.html