|
-
March 7th, 2010, 07:04 PM
#2
Re: Numbers Only Textboxes!!
Although I haven't tested the above code , It should work just fine....but I have found and successfully used following bit of code.....Hope this Helps someone along the way.....
Code:
private void textBox1_PreviewTextInput(object sender, TextCompositionEventArgs e)
{
foreach(char c in e.Text)
{
if (!char.IsDigit(c))
{
e.Handled = true;
break;
}
}
}
for this method to work you need to select the exact textbox and go to eventlist button in the Property window......search for PreviewTextInput and double click it....it will automatically generate the event for you...now enter the code inside that event braces......
This has some loop holes like it can take space, we can paste inside here and tab key for shifting between the various window element is absent etc.....so any one have idea maintaining that please help, although my initial requirement is fullfilled by this bit of code.....Thanks.....
Last edited by rocky_upadhaya; March 7th, 2010 at 07:11 PM.
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
|