I am using textboxes to send text via SendKeys, but when I insert special characters in the textbox, my application crashes. For example, when I put in a '+' in the textbox, I get this error: SendKeys string '+' is not valid.
I need a solution to send special characters with SendKeys, this is a part of my code:
SendKeys.Send(dropDownEffectsLeft1.SelectedItem.ToString() + dropDownEffectsRight1.SelectedItem.ToString() + txt1.Text);
It's all about the textbox called txt1
I think I need something like a Regex
to check if my txt
contains any special characters, and that I will do with:
Regex specialChar = new Regex(@"^[[email protected]]*$");
I really appreciate your help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…