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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing entries in edit boxes?

Status
Not open for further replies.

OOP

Programmer
Feb 5, 2001
94
SG
Hello, i've encountered a problem with how to clear the entries in two edit boxes when a push button is clicked. I've tried the Clear() function but fails. Your feedback/help would be appreciated. Thanks.
 
Depending how you are using the edit controls e.g.
1. The controls are associated with tow CEdit objects:
CEdit m_edText2;
CEdit m_edText1;
then on your handler
void CMyView::OnButtonClear1()
{
m_edText1.SetWindowText("");
m_edText2.SetWindowText("");

}
Note that the DoDataExchage () should contains:
DDX_Control(pDX, IDC_EDIT1, m_edText1);
DDX_Control(pDX, IDC_EDIT2, m_edText2);

2. The edit box controls are associated with tow CString variables:
CString m_sLastName;
CString m_sFirstName;
Then the handler of the button when you want to reset should be :

void CEx10View::OnButtonClear2()
{
m_sLastName.Empty();
m_sFirstName.Empty();
UpdateData(false);

}
and the DoDataExchange() should include :

DDX_Text(pDX, IDC_EDIT1, m_sLastName);
DDX_Text(pDX, IDC_EDIT2, m_sFirstName);

-obislavu-
 
Thanks obislavu,

I've managed to clear the edit box by using the following codes;

box = "";
UpdateData(FALSE);

*where box is a variable which i add to the edit box with the properties you've listed.

i didnt use the DoDataExchange() function thou.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top