在多个spellBox中使用拼写检查

时间:2017-05-31 08:43:21

标签: c# wpf winforms

我想使用这个正则表达式来更改从WCF工具箱导入的所有spellBox spellBoxes。该方法将用户输入更改为标题大小写,因此每个单词的开头都是大写字母。我希望在我的胜利中使用我的所有拼写文本框而不是在每个文本框中重新输入相同的函数,这将是在我的WinForms项目中使用它的最佳方式,以使其更高效,而不必使用它在我的所有文本框上,如15。

因为我还使用了WCF拼写框并集成到我的WinForms项目中,我也无法使用我的spellBox上的.Select无法正常工作,因为它首先在WPF textBox上创建。那么我如何在多个SpellBoxes上使用此函数以及如何使用.select方法,就像我在WPF上TextBox

一样
string myText = txt_HouseName.Text;
var regex = new Regex(@"[^a-zA-Z0-9\s]");// regex to change user input into Title Case.

if (myText.Equals("") || (regex.IsMatch(myText.ToString()))) // validate that the input is not a char or or null
{
    MessageBox.Show("Please enter a valid value, no special chars or leaving this blank!!!!");
}

else
{
   txt_HouseName.Text = System.Threading.Thread.CurrentThread.CurrentCulture.TextInf‌‌o.ToTitleCase(txt_HouseName.Text.ToLow‌er());
                txt_HouseName.Focus();
                txt_HouseName.Select(txt_HouseName.Text.Length, 0);

                //Move Cursor to location of where error
}

0 个答案:

没有答案
相关问题