MaskedTextProvider.InsertAt 方法

定義

在格式化字串中的特定位置插入字元或字串。Inserts a character or string at a specific position within the formatted string.

多載

InsertAt(Char, Int32)

在格式化字串中的指定位置插入指定字元。Inserts the specified character at the specified position within the formatted string.

InsertAt(String, Int32)

在格式化字串中的指定位置插入指定字串。Inserts the specified string at a specified position within the formatted string.

InsertAt(Char, Int32, Int32, MaskedTextResultHint)

在格式化字串中的指定位置插入指定字元,並傳回上一個插入位置和作業狀態。Inserts the specified character at the specified position within the formatted string, returning the last insertion position and the status of the operation.

InsertAt(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.

InsertAt(Char, Int32)

在格式化字串中的指定位置插入指定字元。Inserts the specified character at the specified position within the formatted string.

public:
 bool InsertAt(char input, int position);
public bool InsertAt (char input, int position);
member this.InsertAt : char * int -> bool
Public Function InsertAt (input As Char, position As Integer) As Boolean

參數

input
Char

要插入的 CharThe Char to be inserted.

position
Int32

格式化字串中要插入字元之以零起始的位置。The zero-based position in the formatted string to insert the character.

傳回

如果插入成功,則為 true,否則為 falsetrue if the insertion was successful; otherwise, false.

備註

方法會將字元插入至pos參數所指定的第一個編輯位置或之後。 InsertAtThe InsertAt method inserts a character into the first edit position at or beyond that specified by the pos parameter. 這個方法會將插入點之後的所有現有字元移到一個位置上,以騰出空間給input所插入的字元。This method will shift all existing characters after the insertion point over by one position to make room for the inserted input character. 如果發生下列其中一個錯誤,則不會執行插入動作,且方法false會傳回。If one of the following errors occurs, the insertion is not performed, and the method returns false.

  • 參數小於零或大於Length格式化字串的。 posThe pos parameter is less than zero or greater than the Length of the formatted string.

  • 在指定位置的或以外的格式化字串中, pos找不到可編輯的字元。An editable character was not found in the formatted string at or beyond the specified position, pos.

  • 插入字元不是input有效的輸入字元,因為它無法列印或不符合其對應的遮罩元素。The insertion character, input, is not a valid input character because it is not printable or does not match its corresponding mask element.

  • 插入點右側沒有可用的位置,因此無法移動現有的字元。There are no 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.

input字串不會在格式化的字串中進行任何變更,但true會傳回。An empty input string will cause no change in the formatted string, but will return true.

另請參閱

InsertAt(String, Int32)

在格式化字串中的指定位置插入指定字串。Inserts the specified string at a specified position within the formatted string.

public:
 bool InsertAt(System::String ^ input, int position);
public bool InsertAt (string input, int position);
member this.InsertAt : string * int -> bool
Public Function InsertAt (input As String, position As Integer) As Boolean

參數

input
String

要插入的 StringThe String to be inserted.

position
Int32

格式化字串中要插入輸入字串之以零起始的位置。The zero-based position in the formatted string to insert the input string.

傳回

如果插入成功,則為 true,否則為 falsetrue if the insertion was successful; otherwise, false.

例外狀況

input 參數為 nullThe input parameter is null.

備註

方法會將input字串中的每個字元插入位於位置pos和之後的編輯位置。 InsertAtThe 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. 如果發生下列其中一個錯誤,則不會執行任何插入動作,而且方法false會傳回。If one of the following errors occurs, no insertion is performed, and the method returns false.

  • 參數小於零或大於Length格式化字串的。 posThe pos parameter is less than zero or greater than the Length of the formatted string.

  • 在指定的位置或以外的格式字串中, pos沒有足夠的可編輯字元存在,以插入input字串中的所有字元。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.

input字串不會在格式化的字串中進行任何變更,但true會傳回。An empty input string will cause no change in the formatted string, but will return true.

另請參閱

InsertAt(Char, Int32, Int32, MaskedTextResultHint)

在格式化字串中的指定位置插入指定字元,並傳回上一個插入位置和作業狀態。Inserts the specified character at the specified position within the formatted string, returning the last insertion position and the status of the operation.

public:
 bool InsertAt(char input, int position, [Runtime::InteropServices::Out] int % testPosition, [Runtime::InteropServices::Out] System::ComponentModel::MaskedTextResultHint % resultHint);
public bool InsertAt (char input, int position, out int testPosition, out System.ComponentModel.MaskedTextResultHint resultHint);
member this.InsertAt : char * int * int * MaskedTextResultHint -> bool
Public Function InsertAt (input As Char, position As Integer, ByRef testPosition As Integer, ByRef resultHint As MaskedTextResultHint) As Boolean

參數

input
Char

要插入的 CharThe Char to be inserted.

position
Int32

格式化字串中要插入字元之以零起始的位置。The zero-based position in the formatted string to insert the character.

testPosition
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
MaskedTextResultHint

MaskedTextResultHint,簡潔描述插入作業的結果。A MaskedTextResultHint that succinctly describes the result of the insertion operation. 輸出參數。An output parameter.

傳回

如果插入成功,則為 true,否則為 falsetrue if the insertion was successful; otherwise, false.

備註

方法會將字元插入至pos參數所指定的第一個編輯位置或之後。 InsertAtThe InsertAt method inserts a character into the first edit position at or beyond that specified by the pos parameter. 這個方法會將插入點之後的所有現有字元移到一個位置上,以騰出空間給input所插入的字元。This method will shift all existing characters after the insertion point over by one position to make room for the inserted input character. 如果發生下列其中一個錯誤,則不會執行插入動作,且方法false會傳回。If one of the following errors occurs, the insertion is not performed, and the method returns false.

  • 參數小於零或大於Length格式化字串的。 posThe pos parameter is less than zero or greater than the Length of the formatted string.

  • 在指定位置的或以外的格式化字串中, pos找不到可編輯的字元。An editable character was not found in the formatted string at or beyond the specified position, pos.

  • 插入字元不是input有效的輸入字元,因為它無法列印或不符合其對應的遮罩元素。The insertion character, input, is not a valid input character because it is not printable or does not match its corresponding mask element.

  • 插入點右側沒有可用的位置,因此無法移動現有的字元。There are no 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.

input字串不會在格式化的字串中進行任何變更,但true會傳回。An empty input string will cause no change in the formatted string, but will return true.

另請參閱

InsertAt(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.

public:
 bool InsertAt(System::String ^ input, int position, [Runtime::InteropServices::Out] int % testPosition, [Runtime::InteropServices::Out] System::ComponentModel::MaskedTextResultHint % resultHint);
public bool InsertAt (string input, int position, out int testPosition, out System.ComponentModel.MaskedTextResultHint resultHint);
member this.InsertAt : string * int * int * MaskedTextResultHint -> bool
Public Function InsertAt (input As String, position As Integer, ByRef testPosition As Integer, ByRef resultHint As MaskedTextResultHint) As Boolean

參數

input
String

要插入的 StringThe String to be inserted.

position
Int32

格式化字串中要插入輸入字串之以零起始的位置。The zero-based position in the formatted string to insert the input string.

testPosition
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
MaskedTextResultHint

MaskedTextResultHint,簡潔描述插入作業的結果。A MaskedTextResultHint that succinctly describes the result of the insertion operation. 輸出參數。An output parameter.

傳回

如果插入成功,則為 true,否則為 falsetrue if the insertion was successful; otherwise, false.

例外狀況

input 參數為 nullThe input parameter is null.

備註

方法會將input字串中的每個字元插入位於位置pos和之後的編輯位置。 InsertAtThe 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. 如果發生下列其中一個錯誤,則不會執行任何插入動作,而且方法false會傳回。If one of the following errors occurs, no insertion is performed, and the method returns false.

  • 參數小於零或大於Length格式化字串的。 posThe pos parameter is less than zero or greater than the Length of the formatted string.

  • 在指定的位置或以外的格式字串中, pos沒有足夠的可編輯字元存在,以插入input字串中的所有字元。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.

input字串不會在格式化的字串中進行任何變更,但true會傳回。An empty input string will cause no change in the formatted string, but will return true.

另請參閱

適用於