Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control the entry in a CSpinEdit

Status
Not open for further replies.

Papanatix

Programmer
May 20, 2005
2
ES
Hi everybody. Another doubt:
Does anyone know how can I control when the user puts a letter in a CSpinEdit and not a number, so I can advise him to put a number? (I can only accept numeric data, so I have to control if the user entries a text data instead a numeric data)

Thanksss
 
I've not used the SpinEdit so I don't know if this will work. On regular edit components, I put a call to a function in the OnExit event. The function then takes the string entered into the component, and in a try...catch statement, trys to convert the string into a number. If the conversion fails, the catch statement spits out a warning and puts the user back on the edit box.

I can show you the code but like I say, I've never used the SpinEdit so I don't know how well that will work.



James P. Cottingham
-----------------------------------------
I'm number 1,229!
I'm number 1,229!
 
void __fastcall TForm1::CSpinEdit1KeyPress(TObject *Sender, char &Key)
{
if (!isdigit (Key))
{
Key = NULL;
ShowMessage ("Please Input a Number");
}
}

tomcruz.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top