Click here to Skip to main content
15,880,469 members
Articles / Desktop Programming / MFC
Article

Advanced Numeric Edit Control

Rate me:
Please Sign up or sign in to vote.
4.50/5 (9 votes)
2 Dec 2001 115.5K   5.2K   41   17
An edit control that provides formatting and validation number

Sample Image - XRNumericEditCtrl.jpg

Introduction

The CXrNumericEdit class is derived from the normal CEdit class.

To use this class

  • Add the CXrNumericEdit source file to project.
  • Add standard edit control
  • Change CEdit class to CXrNumericEdit
    public:
        //Dialog Data
    	//{{AFX_DATA(CNumericEditDlg)
    	enum { IDD = IDD_NUMERICEDIT_DIALOG };
    	CXrNumericEdit	m_ctrlPositiveValue;

To get and set the value in the CXrNumericEdit control use the DDX functions.

void CNumericEditDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CNumericEditDlg)
    DDX_Text(pDX, IDC_POSITIVE_SAMPLE, m_dbPositiveValue);
	...
	//}}AFX_DATA_MAP
}

Thanks to

  • Randy More for 'All you ever wanted to know about the Clipboard'
  • Ian J Hart by Number, Currency, Percentage Edit Control
  • Dundas Software for the Masked Edit Control

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Cuba Cuba
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralOh, my god! No Any Note Pin
fishyoungman15-Jan-13 15:51
fishyoungman15-Jan-13 15:51 
GeneralNegative value flaws Pin
Raul Sobon19-Dec-07 19:17
Raul Sobon19-Dec-07 19:17 
GeneralA Bug! Pin
Ali Khanlarkhani1-Dec-07 21:10
Ali Khanlarkhani1-Dec-07 21:10 
First, thanx for you nice control.Rose | [Rose]
I used it in many projects succesfuly.Cool | :cool:
Currentlly I encountered with a problem:
It is impossible to copy data to clipboard by context menu.Sleepy | :zzz:
Please try:
1) right click in control
2) from context menu select 'copy'

ThanxSmile | :)

GeneralCreating the DLL Pin
kevinlkingma22-Nov-06 2:46
kevinlkingma22-Nov-06 2:46 
GeneralLimitText( nMax ) is invalid Pin
allehiman30-May-06 18:19
allehiman30-May-06 18:19 
Questioncan I mention your name in my app? Pin
Ștefan-Mihai MOGA11-Apr-06 23:01
professionalȘtefan-Mihai MOGA11-Apr-06 23:01 
GeneralRegional Settings Pin
JDonovan20-Nov-03 13:38
JDonovan20-Nov-03 13:38 
GeneralRe: Regional Settings Pin
Mátyásföldi Imre1-Oct-07 23:24
professionalMátyásföldi Imre1-Oct-07 23:24 
GeneralError with Buddy Control Pin
JDonovan20-Nov-03 5:45
JDonovan20-Nov-03 5:45 
GeneralThere is also a bug... Pin
hukurou5008-Oct-03 0:03
hukurou5008-Oct-03 0:03 
GeneralCan't Properly Set Sel Pin
forrest.mao28-May-03 17:30
forrest.mao28-May-03 17:30 
GeneralSuggestion Pin
Stlan27-Jan-03 21:12
Stlan27-Jan-03 21:12 
QuestionA bug? Pin
Member 117662579-Oct-02 6:59
Member 117662579-Oct-02 6:59 
GeneralCreate Pin
22-Feb-02 2:50
suss22-Feb-02 2:50 
GeneralRe: Create Pin
jmarcos10-Sep-02 19:16
jmarcos10-Sep-02 19:16 
GeneralMissing header Pin
John P. Curtis3-Dec-01 19:17
John P. Curtis3-Dec-01 19:17 
GeneralRe: Missing header Pin
3-Dec-01 21:30
suss3-Dec-01 21:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.