A range validation Edit control
Posted
by Donald R. Kichline
on August 6th, 1998
In a project that I am working with about 6 people, we were using spin controls and edit controls to allow the operator to change certain values. We decided we needed one way to handle invalid data typed in the edit control by the operator. The best solution we came up with was to sub-class CEdit, and validate the operators key-strokes.
- Ensure that the edit control has the number only style set to TRUE.
- Then you need to include the "CRangeEdit.h" in your dialog definition file, and declare CRangeEdit member variables for each edit control that you need to check the range of an operators input.
- Then you must set the range the CRangeEdit will accept from the operator, using the CRangeEdit::SetRange() method. The CRangeEdit will default to 0-100 range.
- Set the default contents of the control using CWnd::SetWindowText().
You should be ready to go!
Last updated: 29 April 1998

Comments
Why not DDV??
Posted by zmdmustafa on 04/08/2004 05:02amWith the help of class wizard we can use DDV to handle the same, why to take all these pain?
ReplyQuestion
Posted by Legacy on 08/06/2002 12:00amOriginally posted by: Ramesh
I have an Edit Control in VC++, and I basically use it for logging. So I assign the member variable to the log info I wanr and then I use the UpdateData(FALSE).
ReplyNow the proble I have is I want the new line charter to function as new line, but instead it display some special character there. How do I send a new line character to my Edit Control.
Min Max
Posted by Legacy on 06/06/2002 12:00amOriginally posted by: Derrick
I think your idea is great but, there is still a small problem. The code works fine when setting a MIN value of 0 but anything above the code doesn't work properly.
-
Replytrail
Posted by mallikarjuna_kilari on 08/05/2007 11:45amjust for checking i asked that que.
ReplyExEditors Library
Posted by Legacy on 03/19/2002 12:00amOriginally posted by: Mike Philips
ReplyA little enhancement
Posted by Legacy on 08/06/1999 12:00amOriginally posted by: Marcelo Rego
Reply