How to Validate the Text in a TextBox

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Apr 2008
Posts: 22
Reputation: Indianblues is an unknown quantity at this point 
Solved Threads: 0
Indianblues Indianblues is offline Offline
Newbie Poster

How to Validate the Text in a TextBox

 
0
  #1
Nov 22nd, 2008
Hi,

I want to validate the text in a textbox. Actually i am trying to enter to amount in the textbox. If other than integer is entered in the textbox , it should say " please enter integer value ". Can somebody pls tell me how to do this. ( With out using try catch block)

Thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,943
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 280
ddanbe's Avatar
ddanbe ddanbe is offline Offline
Posting Virtuoso

Re: How to Validate the Text in a TextBox

 
0
  #2
Nov 22nd, 2008
Use the Validated or Validating events of your textbox.
Something like:
private void Mytextbox_Validating(object sender,CancelEventAgrs e)
{
//check for int
//if not int:
// e.Cancel = true;
// MessageBox.Show("You need to enter an integer");
}
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC