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
275
How do you add a ValueConstraint to a field?
posted

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

Parents
No Data
Reply
  • 28464
    posted

    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

     

Children
No Data