本文整理汇总了C#中System.ComponentModel.MaskedTextProvider.ToDisplayString方法的典型用法代码示例。如果您正苦于以下问题:C# MaskedTextProvider.ToDisplayString方法的具体用法?C# MaskedTextProvider.ToDisplayString怎么用?C# MaskedTextProvider.ToDisplayString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.MaskedTextProvider
的用法示例。
在下文中一共展示了MaskedTextProvider.ToDisplayString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CoerceText
private static object CoerceText(DependencyObject d, object value)
{
MaskedTextBox textBox = (MaskedTextBox)d;
MaskedTextProvider maskProvider = new MaskedTextProvider(textBox.Mask);
maskProvider.Set((string)value);
return maskProvider.ToDisplayString();
}
示例2: ForceText
//force the text of the control to use the mask
private static object ForceText(DependencyObject sender, object value)
{
MaskedTextBox textBox = (MaskedTextBox) sender;
if (textBox.Mask != null)
{
MaskedTextProvider provider = new MaskedTextProvider(textBox.Mask);
provider.Set((string) value);
return provider.ToDisplayString();
}
else
{
return value;
}
}
示例3: MaskedTextBoxLoaded
private void MaskedTextBoxLoaded(object sender, RoutedEventArgs e)
{
_provider = new MaskedTextProvider(!string.IsNullOrEmpty(InputMask) ? InputMask : " ", CultureInfo.CurrentCulture);
_provider.Set(String.IsNullOrWhiteSpace(UnmaskedText) ? String.Empty : UnmaskedText);
_provider.PromptChar = PromptChar;
Text = _provider.ToDisplayString();
DependencyPropertyDescriptor textProp = DependencyPropertyDescriptor.FromProperty(TextProperty,
typeof(MaskedTextBox));
if (textProp != null)
{
textProp.AddValueChanged(this, (s, args) => UpdateText());
}
DataObject.AddPastingHandler(this, Pasting);
}
示例4: RefreshText
private void RefreshText(MaskedTextProvider maskProvider, int pos)
{
// Refresh string.
this.Text = maskProvider.ToDisplayString();
// Position cursor.
this.SelectionStart = pos;
}
示例5: UpdateText
private void UpdateText(MaskedTextProvider provider, int position)
{
if (provider == null)
throw new ArgumentNullException("MaskedTextProvider", "Mask cannot be null.");
Text = provider.ToDisplayString();
SelectionStart = position;
}
示例6: RefreshText
//refreshes the text of the textbox
private void RefreshText(MaskedTextProvider provider, int position)
{
if (provider != null)
{
Text = provider.ToDisplayString();
SelectionStart = position;
}
}
示例7: ToDisplayString
public void ToDisplayString ()
{
MaskedTextProvider mtp;
mtp = new MaskedTextProvider ("##-##");
mtp.PasswordChar = '*';
Assert.AreEqual ("__-__", mtp.ToDisplayString ());
mtp.Add ("666");
Assert.AreEqual ("**-*_", mtp.ToDisplayString ());
}
示例8: GetMaskedInput
private string GetMaskedInput(string name, string primaryFieldFormat)
{
var provider = new MaskedTextProvider(primaryFieldFormat, CultureInfo.CurrentCulture);
provider.Set(name);
return provider.ToDisplayString();
}
示例9: RefreshText
//refreshes the text of the textbox
protected void RefreshText(MaskedTextProvider provider, int position)
{
if (provider == null) return;
Text = provider.ToDisplayString();
SelectionStart = position;
}
示例10: ForceText
protected virtual object ForceText(object value)
{
if (Mask != null)
{
var provider = new MaskedTextProvider(Mask) { PromptChar = PromptChar};
if(value != null)
provider.Set((string)value);
return provider.ToDisplayString();
}
return value;
}
示例11: GetMaskedString
public static string GetMaskedString(string mask, string input)
{
MaskedTextProvider provider = new MaskedTextProvider(mask);
provider.Add(input);
return provider.ToDisplayString();
}