在WPF richtextbox中以大写形式输入文本 [英] Do text entered in WPF richtextbox in uppercase
本文介绍了在WPF richtextbox中以大写形式输入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello All,
问题是当我在WPF richtextBox中输入任何字符时,它应该是大写的。
我们在文本框中使用字符大小写属性。但是对于richtextbox来说却没有什么。
我在谷歌周围但不高兴。
请帮忙。
谢谢
解决方案
您好KIDYA,您可以使用以下代码片段:
private void RichTextBox1_PreviewTextInput( object sender,TextCompositionEventArgs e)
{
TextRange range = new TextRange(RichTextBox1.CaretPosition,RichTextBox1.CaretPosition) ;
range.Text = e.TextComposition.Text.ToUpper();
RichTextBox1.CaretPosition = range.End.GetInsertionPosition(LogicalDirection.Forward);
e.Handled = true ;
}
希望它有所帮助。
它对我有用...非常感谢Christian :)) BLOCKQUOTE>
Hello All,
Problem is when I'm entering any character in WPF richtextBox it should be in uppercase.
We use character case property in textbox. But nothing like it for richtextbox.
I google around it but not happy.
Please help.
Thanks解决方案Hi KIDYA, You can use the following code snippet:
private void RichTextBox1_PreviewTextInput(object sender, TextCompositionEventArgs e) { TextRange range = new TextRange(RichTextBox1.CaretPosition, RichTextBox1.CaretPosition); range.Text = e.TextComposition.Text.ToUpper(); RichTextBox1.CaretPosition = range.End.GetInsertionPosition(LogicalDirection.Forward); e.Handled = true; }
Hope it helps.
It worked for me...Thanks a lot Christian :)
这篇关于在WPF richtextbox中以大写形式输入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文