in
Forums
Blogs
Files
Devexpress.Com
Client Center
Support Center
DevExpress Channel

How to change/update editmask in runtime?

Last post 1/14/2008 10:47 AM by Xavier Nuyttens. 2 replies.
Page 1 of 1 (3 items)
Sort Posts:
Previous Next
  • 9/5/2007 8:29 PM

    How to change/update editmask in runtime?

    How can I change/update editmask in runtime?  

     

    I have a class like that:

    public class Customers : BaseObject
        {
            public Customers(Session session)
                : base(session)
            {
            }

            private Countries counties;
            public Countries Countries
            {
                get
                {
                    return counties;
                }
                set
                {
                    counties = value;
                    OnChanged("Countries");
                }
            }
            private string customerName;
            public string CustomerName
            {
                get
                {
                    return customerName;
                }
                set
                {
                    customerName = value;
                    OnChanged("CustomerName");
                }
            }
            private string customerPhone;
            public string CustomerPhone
            {
                get
                {
                    return customerPhone;
                }
                set
                {
                    customerPhone = value;
                    OnChanged("CustomerPhone");
                }
            }
        }
        public enum Countries {
            Australia,
            Brazil,
            Russia
        }
     


    When i choose in combobox Australia,I want to set (00)0000 0000 in EditMask of CustomerPhone.
    If I choose Russia , I want to set (99)000 000 000 like that
    How can i do it in runtime?

    Filed under:
  • 9/13/2007 10:18 AM In reply to

    Re: How to change/update editmask in runtime?

    >>

    Hi,

    To accomplish this behavior, perform the following steps.

    1) Create a ViewController and add a method that will set the appropriate mask.
        private void ChangeEditorMask()
         {
            PropertyEditor editor=((PropertyEditor)((DetailView)View).FindItem("CustomerPhone"));
            string str = ((Customer)View.CurrentObject).Countries.ToString();
            switch (str)
            {
                case "Australia":
                    ((TextEdit)editor.Control).Properties.Mask.EditMask = "(0)0";
                    ((TextEdit)editor.Control).Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Simple;
                    break;
                case "Brazil":
                    ((TextEdit)editor.Control).Properties.Mask.EditMask = "(00)00";
                    ((TextEdit)editor.Control).Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Simple;
                    break;
                case "Russia":
                    ((TextEdit)editor.Control).Properties.Mask.EditMask = "(000)000";
                    ((TextEdit)editor.Control).Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Simple;
                    break;
            }
      }

    2) Subscribe to these events: View.ControlsCreated editor.ControlValueChanged (the editor.PropertyName="Countries"). In these event handlers, call the ChangeEditorMask() method.

    There is a similar entry in the Support center at

    http://www.devexpress.com/Support/Center/p/Q20162.aspx
    Thanks,
    Dennis

    Developer Express Support
  • 1/14/2008 10:47 AM In reply to

    Re: How to change/update editmask in runtime?

    This approach works when using in the Win app. Is there a possibility to change the code so it works for both Win & Web ? I'd like to put as much code as possible in the App.Module.

    Greetings
    Xavier

Page 1 of 1 (3 items)
Copyright © 1998-2008 Developer Express Inc.
ALL RIGHTS RESERVED