Click here to Skip to main content
16,007,687 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
WINFORM APP

here i have a text box if i entered characters like({,º,º, Ñ, ö ) using alt button the text box has to throw exception with loadxml()

What I have tried:

i used loadxml() to load the XML and i want to know if there is any method that can check the characters alt keywords and other characters
Posted
Updated 27-Aug-17 23:07pm
v3
Comments
Graeme_Grant 28-Aug-17 4:28am    
We need a little bit of context as we can't see your screen from here... What type of app are you developing? Winform, Wpf, Xamarin, WebForm, MVC, etc...? Click on the "Improve question" widget and update your question.
Member 13375990 28-Aug-17 4:29am    
winforms sir
Graeme_Grant 28-Aug-17 4:44am    
If you don't hit the "reply" button on my comment, I don't get alerted to your reply.

I have updated the type of app.
Member 13375990 29-Aug-17 1:26am    
the solution not working sir if typed alt+123 "{" is entered how to restrict those keys
Graeme_Grant 29-Aug-17 2:04am    
I've given you several different ways of doing it with one example of how you could possibly do it. Now, as a programmer, it is up to you to complete the solution using the method that you find most suitable.

1 solution

As a "programmer", programming is solving problems.

There are several ways to "validate" user input. Here are two:

1. To disallow invalid input as it is entered - the TextBox's KeyDown event and block invalid value. For example:
C#
private void txtSomeField_KeyDown(object sender, KeyEventArgs e)
{
    e.SuppressKeyPress = e.KeyValue < 34 || e.KeyValue > 127;
}

2. Only enable the SAVE/OK/etc... button if the input is valid

The third option is to check the user input after the SAVE button is pressed.
 
Share this answer
 
Comments
Member 13375990 29-Aug-17 1:19am    
tq sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900