Re: Simple C# validation.
1 - I added the event handler how you told me to do it.
2 - You are allowed to write numbers. This is what im trying to stop. At the minute, if i type a number into the text box, they appear as normal.
3 - The only code in that button is what you have provided:
private void nameTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
if (Char.IsNumber(e.KeyChar))
{
e.Handled = true;
MessageBox.Show("Error");
}
}
Re: Simple C# validation.
If you already had this function and then tried to add the event handler, you would get a routine named: nameTextBox_KeyPress1.
Check back in the form initialization to see what method is being assoiciated with the KeyPressed Event.....
Re: Simple C# validation.
Sorted it!
It was due to another, unrelated compilation error (from another problem that would be way too complicated to explain, unfortunately).
Its working perfectly now - thank you so much.
Re: Simple C# validation.
Quote:
It was due to another, unrelated compilation error
How/Why did you RUN the program with a Compilation Error??? :confused: :confused: