-
CComboBox
Hello- does anyone know how to retreive the Edit box's text from a dropdown combobox?
I can get the current selection etc. but this is useless if there is no selection, i.e. when the user is entering their own data. Nowhere does there appear to be a function to get the text from the editbox :(
I guess it's there and that it's staring me in the face but could anyone point it out?
(I'm using MFC.)
Thanks in advance
dt
/////////////////////////////////////////////////
UPDATE
/////////////////////////////////////////////////
Sorry, I'm thick,
Code:
CWnd::GetWindowText(CString&)
That's the one.
-
CComboBox
You use CComboBox::GetWindowText(CString&);
If it is in a dialog you need to use GetDlgItem(IDC_whatever)
You also need a CString variable to store the text or a C-string (char array). Note: GetDlgItem() does not need to work with a Dialog, the name is miss-leading. It will get the Item by ID even if it is in a window of a MDI or SDI style program.
Code:
// pretend your id your Combo Box as IDC_COMBOBOX
CComboBox* pCB = (CComboBox*)GetDlgItem(IDC_COMBOBOX);
CString str;
pCB->GetWindowText(str);
-
cheers velius - I'd actually already worked it out - I guess my update wasnt very clear, sorry.
Thanks for your time anyways,
dt
-
Don't mention it. I love answering questions. Yeah now that I read it in the context of you changed it to say you found it, I can see that now.
-