System.ComponentModel.MaskedTextProvider.Set C# (CSharp) Method

Set() public method

Sets the edit characters in the test string to the ones specified in the input string if all characters are valid. On exit the testPosition contains last position where the primary operation was actually performed if successful, otherwise the first position that made the test fail. This position is relative to the test string. The MaskedTextResultHint out param gives more information about the operation result. If passwordChar is assigned, it is rendered in the output string instead of the user-supplied values.
public Set ( string input, int &testPosition, MaskedTextResultHint &resultHint ) : bool
input string
testPosition int
resultHint MaskedTextResultHint
return bool
        public bool Set(string input, out int testPosition, out MaskedTextResultHint resultHint)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            resultHint = MaskedTextResultHint.Unknown;
            testPosition = 0;

            if (input.Length == 0) // Clearing the input text.
            {
                Clear(out resultHint);
                return true;
            }

            if (!TestSetString(input, testPosition, out testPosition, out resultHint))
            {
                return false;
            }

            // Reset remaining characters (if any).
            int resetPos = FindAssignedEditPositionFrom(testPosition + 1, forward);

            if (resetPos != invalidIndex)
            {
                ResetString(resetPos, _testString.Length - 1);
            }

            return true;
        }

Same methods

MaskedTextProvider::Set ( string input ) : bool

Usage Example

Example #1
1
 private static object CoerceText(DependencyObject d, object value)
 {
     MaskedTextBox textBox = (MaskedTextBox)d;
     MaskedTextProvider maskProvider = new MaskedTextProvider(textBox.Mask);
     maskProvider.Set((string)value);
     return maskProvider.ToDisplayString();            
 }
All Usage Examples Of System.ComponentModel.MaskedTextProvider::Set