public class AutoCapizalizeTextBox: TextBox
{
public AutoCapitalizeTextBox()
{
}
public AutoCapitlizeTextBox()
{
}
protected override void OnLostFocus(EventArgs e)
{
this.Text = this.Text.ToUpper();
base.OnLostFocus(e);
}
}
I recommend creating a custom Textbox class and override an event to automatically capitalize the text. First, this depends on if you want the text to be capitalize as they type or after input is finished.
E.g. for after input is finished
public class AutoCapizalizeTextBox: TextBox
{
public AutoCapitalizeTextBox()
{
}
public AutoCapitlizeTextBox()
{
}
protected override void OnLostFocus(EventArgs e)
{
this.Text = this.Text.ToUpper();
base.OnLostFocus(e);
}
}
发布评论
评论(5)
您可以使用以下属性对
TextBox
控件中的所有输入进行大小写:要应用于整个应用程序中的所有
TextBox
控件,请为所有TextBox
创建一个样式控制:You can case all input into
TextBox
controls with the following property:To apply to all
TextBox
controls in the entire application create a style for allTextBox
controls:如果您想将单个
TextBox
的输入大写,而不是像 TextBoxes >上面,您可以使用以下内容:If you want to capitalize the input for a single
TextBox
rather than allTextBox
es like above, you can use the following:我建议创建一个自定义 Textbox 类并覆盖一个事件以自动将文本大写。 首先,这取决于您是否希望文本在键入时或输入完成后大写。
例如输入完成后
I recommend creating a custom Textbox class and override an event to automatically capitalize the text. First, this depends on if you want the text to be capitalize as they type or after input is finished.
E.g. for after input is finished
我不知道这是否有帮助,它将句子中的所有第一个字母大写。
http://www.mardymonkey.co .uk/blog/auto-capitalise-a-text-control-in-wpf/
I don't know if this'll help, it capitalizes all the first letters in the sentence.
http://www.mardymonkey.co.uk/blog/auto-capitalise-a-text-control-in-wpf/
也许你可以使用转换器。
这是转换器的代码:
您需要在“ResourceDictionary”或“App.xaml”中引用它:
您可以像这样使用它:
Perhaps you can use a converter.
Here's the code of the converter:
You need to reference it in a "ResourceDictionary" or in your "App.xaml":
And you can use it like this: