MaskedTextProvider.VerifyChar(Char, Int32, MaskedTextResultHint) 方法

定义

测试指定的字符是否可以在指定位置成功设置。Tests whether the specified character could be set successfully at the specified position.

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

参数

input
Char

要测试的 Char 值。The Char value to test.

position
Int32

测试输入字符时所根据的掩码位置。The position in the mask to test the input character against.

hint
MaskedTextResultHint

一个 MaskedTextResultHint,用于简单地描述操作的结果。A MaskedTextResultHint that succinctly describes the result of the operation. 一个输出参数。An output parameter.

返回

Boolean

如果指定的字符对指定位置有效,则为 true;否则为 falsetrue if the specified character is valid for the specified position; otherwise, false.

注解

VerifyChar方法测试单个字符值是否表示格式化字符串中指定位置的有效输入。The VerifyChar method tests whether a single character value represents valid input at the specified position in the formatted string. 此方法将返回 false ,原因如下:This method will return false for the following reasons:

  • pos参数小于零或大于的 Length MaskThe pos parameter is less than zero or greater than the Length of the Mask.

  • 字符 input 不是有效的输入字符,由 IsValidInputChar 方法确定。The character input is not a valid input character, as determined by the IsValidInputChar method.

  • 与位于 input 指定位置的 mask 元素不兼容 posThe input is not compatible with the mask element at the specified position, pos.

最后一个条件可能取决于 AllowPromptAsInput 、、 AsciiOnly PasswordChar PromptCharSkipLiterals 属性的当前值。The last condition may depend on the current value of the AllowPromptAsInput, AsciiOnly, PasswordChar, PromptChar and SkipLiterals properties.

若要针对掩码测试整个输入字符串,请改用其中一种 VerifyString 方法。To test an entire input string against the mask, use one of the VerifyString methods instead.

适用于

另请参阅