|
-
April 1st, 1999, 03:19 PM
#1
selecting text in edit control programmatically
Hello all. I'm a definite newbie so please bear with me. I have a CRecordview with edit controls on it. The edit controls are bound to CString data variables in a database. I would like to be able to highlight the text in the edit control automatically, saving the user from having to use the mouse between every lookup. I tried using the SetSel() function in the EN_SETFOCUS message but I get an error stating that it is not a member of CString. I also tried using CWnd's GetDlgItem(IDC_ITEMNUMBER) but there doesn't seem to be a CWnd function for accomplishing this task. Any assistance is greatly appreciated. Thanks in advance.
Roller8
-
April 1st, 1999, 04:37 PM
#2
Re: From Masaaki Onishi
Hi.
You had better cast GetDlgItem by CEdit*.
CEdit* ptrEdit = (CEdit*)GetDlgItem(IDC_ITEMNUMBER);
Or, use class wizard and make a control the member control.
m_ctlEdit.SetSel(0,-1);
Don't forget that this only works if the editbox has a focus.
Hope for help.
-Masaaki Onishi-
-
April 1st, 1999, 05:16 PM
#3
Re: From Masaaki Onishi
CEdit * ce = (CEdit *)GetDlgItem(IDC_ED1);
ce->SetFocus();
ce->SetSel(0,5,FALSE);
Deep
-
April 1st, 1999, 06:28 PM
#4
Re: From Masaaki Onishi
This worked perfectly! Thank you for your help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|