|
-
Feb 24th, 2005, 12:29 PM
#1
Thread Starter
Junior Member
Intercepting Keys
This is what I want to do:
Code:
if (!Char.IsDigit(e.KeyChar.ToString(), 0) )
{
STOPTHISCHARFROMBEINGENTERED();
}
but e.KeyChar can't be assigned to bc it's readonly.
Help?
Dan
-
Feb 24th, 2005, 05:49 PM
#2
Re: Intercepting Keys
 Originally Posted by dipique
This is what I want to do:
Code:
if (!Char.IsDigit(e.KeyChar.ToString(), 0) )
{
STOPTHISCHARFROMBEINGENTERED();
}
but e.KeyChar can't be assigned to bc it's readonly.
Help?
Dan
Simply use e.Handled=true
Code:
private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (!Char.IsDigit(e.KeyChar.ToString(), 0) )
{
e.Handled=true;
}
}
Dan 
My username elsware is datique which is very similar to you. We are not long lost brothers are we. Lol
[VBF RSS Feed]
There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.
If I have been helpful, Please Rate my Post. Thanks.
This post was powered by : 
-
Feb 25th, 2005, 12:31 PM
#3
Thread Starter
Junior Member
Re: Intercepting Keys
Thanks, that worked wonderfully. As to whether we are long lost brothers... well, I suppose it's possible. But probably not
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|