Restrict Special Characters in Windows Application using c#
Example : In this application it will remove all the special characters when we trying to copy paste the special characters. Lets see how it is possible with Copy,paste. Please follow these steps : 1. Create a New Windows Form with the name of 'Form1', and take one label with the name of 'lblName' and one textbox with the name of 'txtName' and one button with the name of 'btnValidate'. Please see below image. 2. Add a code in TextChanged event for that textbox. Here my textbox name is 'txtName' in that I have added a event like . private void txtName_TextChanged(object sender, EventArgs e) { txtName.Text = RemoveSpecialCharacters(txtName.Text); } 3. In that event you observed method name of 'RemoveSpecialCharacters'.Basically it will remove all the special characters when you are copy paste in to the textbox. private string RemoveSpecialCharacters(String inString) ...