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

InsertAt() public method

Attempts to insert the characters in the specified string in at the specified position in the test string, shifting characters at upper positions (if any) to make room for the input. 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. Returns true on success, false otherwise.
public InsertAt ( string input, int position, int &testPosition, MaskedTextResultHint &resultHint ) : bool
input string
position int
testPosition int
resultHint MaskedTextResultHint
return bool
        public bool InsertAt(string input, int position, out int testPosition, out MaskedTextResultHint resultHint)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            if (position < 0 || position >= _testString.Length)
            {
                testPosition = position;
                resultHint = MaskedTextResultHint.PositionOutOfRange;
                return false;
                //throw new ArgumentOutOfRangeException("position");
            }

            return InsertAtInt(input, position, out testPosition, out resultHint, false);
        }

Same methods

MaskedTextProvider::InsertAt ( char input, int position ) : bool
MaskedTextProvider::InsertAt ( char input, int position, int &testPosition, MaskedTextResultHint &resultHint ) : bool
MaskedTextProvider::InsertAt ( string input, int position ) : bool

Usage Example

Example #1
0
        private bool PlaceCharCore( MaskedTextProvider provider, char ch, int startPosition, int length, bool overwrite, out int caretPosition )
        {
            caretPosition = startPosition;

              if( startPosition < m_maskedTextProvider.Length )
              {
            MaskedTextResultHint notUsed;

            if( length > 0 )
            {
              int endPosition = ( startPosition + length ) - 1;
              return provider.Replace( ch, startPosition, endPosition, out caretPosition, out notUsed );
            }

            if( overwrite )
              return provider.Replace( ch, startPosition, out caretPosition, out notUsed );

            return provider.InsertAt( ch, startPosition, out caretPosition, out notUsed );
              }

              return false;
        }
All Usage Examples Of System.ComponentModel.MaskedTextProvider::InsertAt