本文整理匯總了C#中System.Windows.Forms.MaskedTextBox.ValidateText方法的典型用法代碼示例。如果您正苦於以下問題:C# MaskedTextBox.ValidateText方法的具體用法?C# MaskedTextBox.ValidateText怎麽用?C# MaskedTextBox.ValidateText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.MaskedTextBox
的用法示例。
在下文中一共展示了MaskedTextBox.ValidateText方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: IsValidMaskDescriptor
public static bool IsValidMaskDescriptor(MaskDescriptor maskDescriptor, out string validationErrorDescription)
{
validationErrorDescription = string.Empty;
if (maskDescriptor == null)
{
validationErrorDescription = System.Design.SR.GetString("MaskDescriptorNull");
return false;
}
if ((string.IsNullOrEmpty(maskDescriptor.Mask) || string.IsNullOrEmpty(maskDescriptor.Name)) || string.IsNullOrEmpty(maskDescriptor.Sample))
{
validationErrorDescription = System.Design.SR.GetString("MaskDescriptorNullOrEmptyRequiredProperty");
return false;
}
MaskedTextProvider maskedTextProvider = new MaskedTextProvider(maskDescriptor.Mask, maskDescriptor.Culture);
MaskedTextBox box = new MaskedTextBox(maskedTextProvider) {
SkipLiterals = true,
ResetOnPrompt = true,
ResetOnSpace = true,
ValidatingType = maskDescriptor.ValidatingType,
FormatProvider = maskDescriptor.Culture,
Culture = maskDescriptor.Culture
};
box.TypeValidationCompleted += new TypeValidationEventHandler(MaskDescriptor.maskedTextBox1_TypeValidationCompleted);
box.MaskInputRejected += new MaskInputRejectedEventHandler(MaskDescriptor.maskedTextBox1_MaskInputRejected);
box.Text = maskDescriptor.Sample;
if ((box.Tag == null) && (maskDescriptor.ValidatingType != null))
{
box.ValidateText();
}
if (box.Tag != null)
{
validationErrorDescription = box.Tag.ToString();
}
return (validationErrorDescription.Length == 0);
}