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

FindNonEditPositionFrom() public method

Gets the position of the first non edit position in the test string; the search is performed from the specified position and in the specified direction. The positions are relative to the test string. Returns InvalidIndex if it doesn't find one.
public FindNonEditPositionFrom ( int position, bool direction ) : int
position int
direction bool
return int
        public int FindNonEditPositionFrom(int position, bool direction)
        {
            int startPosition;
            int endPosition;

            if (direction == forward)
            {
                startPosition = position;
                endPosition = _testString.Length - 1;
            }
            else
            {
                startPosition = 0;
                endPosition = position;
            }

            return FindNonEditPositionInRange(startPosition, endPosition, direction);
        }

Usage Example

Example #1
0
        private bool ShouldQueryAutoCompleteMask( MaskedTextProvider provider, char ch, int startPosition )
        {
            if( provider.IsEditPosition( startPosition ) )
              {
            int nextSeparatorIndex = provider.FindNonEditPositionFrom( startPosition, true );

            if( nextSeparatorIndex != -1 )
            {
              if( provider[ nextSeparatorIndex ].Equals( ch ) )
              {
            int previousSeparatorIndex = provider.FindNonEditPositionFrom( startPosition, false );

            if( provider.FindUnassignedEditPositionInRange( previousSeparatorIndex, nextSeparatorIndex, true ) != -1 )
            {
              return true;
            }
              }
            }
              }

              return false;
        }