MaskedTextProvider.InsertAt Method (String, Int32, Int32, MaskedTextResultHint)

Inserts the specified string at a specified position within the formatted string, returning the last insertion position and the status of the operation.

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

public bool InsertAt(
	string input,
	int position,
	out int testPosition,
	out MaskedTextResultHint resultHint
)

Parameters

input
Type: System.String

The String to be inserted.

position
Type: System.Int32

The zero-based position in the formatted string to insert the input string.

testPosition
Type: System.Int32

If the method is successful, the last position where a character was inserted; otherwise, the first position where the insertion failed. An output parameter.

resultHint
Type: System.ComponentModel.MaskedTextResultHint

A MaskedTextResultHint that succinctly describes the result of the insertion operation. An output parameter.

Return Value

Type: System.Boolean
true if the insertion was successful; otherwise, false.

ExceptionCondition
ArgumentNullException

The input parameter is null.

The InsertAt method inserts each character from the input string into the edit positions located at position pos and beyond. This method will shift all existing characters after the insertion point over by one position for each inserted character. If one of the following errors occurs, no insertion is performed, and the method returns false.

  • The pos parameter is less than zero or greater than the Length of the formatted string.

  • Not enough editable characters exist in the formatted string at or beyond the specified position, pos, to insert all of the characters from the input string.

  • One or more of the insertion characters are not a valid input character because they are not printable or do not match their corresponding mask element.

  • There are not enough available positions to the right of the insertion point, so that existing characters cannot be shifted.

  • Shifting the existing characters would produce a violation of the mask. Note that this shifting occurs during the insertion of each individual character.

An empty input string will cause no change in the formatted string, but will return true.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft