CCombobox MFC vc++
-
I have created a CCombobox drop down and added three data through wizards and disable editing. I wanted to display some data/word initially in the edit ctrl part of the CCombobox before selecting the data present in the drop down.I having difficulty achieving this, could I have some pointers regarding this. Thanks in advance.
-
I have created a CCombobox drop down and added three data through wizards and disable editing. I wanted to display some data/word initially in the edit ctrl part of the CCombobox before selecting the data present in the drop down.I having difficulty achieving this, could I have some pointers regarding this. Thanks in advance.
To display some existing (in the combo listbox) item use CComboBox::SetCurSel. To display some arbitrary text you could use SetWindowText method.
-
I have created a CCombobox drop down and added three data through wizards and disable editing. I wanted to display some data/word initially in the edit ctrl part of the CCombobox before selecting the data present in the drop down.I having difficulty achieving this, could I have some pointers regarding this. Thanks in advance.
-
To display some existing (in the combo listbox) item use CComboBox::SetCurSel. To display some arbitrary text you could use SetWindowText method.
Thanks for replying. Yes, I've tried using SetWindowText method. It's not showing in the combo box. What I wanted was when I start my application it shows something like "please select something" before I select anything. For edit ctrl box... We assigned something to the CSting variable and do UpdataData(FALSE).. I wanted to do something similar like this. Thanks again.
-
Thanks for replying. Yes, I've tried using SetWindowText method. It's not showing in the combo box. What I wanted was when I start my application it shows something like "please select something" before I select anything. For edit ctrl box... We assigned something to the CSting variable and do UpdataData(FALSE).. I wanted to do something similar like this. Thanks again.
Member 14575556 wrote:
What I wanted was when I start my application it shows something like "please select something" before I select anything.
Are you doing something like:
m_list.AddString(_T("Item 1"));
m_list.AddString(_T("Item 2"));
m_list.AddString(_T("Item 3"));
m_list.AddString(_T("Item 4"));
m_list.InsertItem(0, _T("please select something"));
...
m_list.SetCurSel(0);"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Thanks for replying. Yes, I've tried using SetWindowText method. It's not showing in the combo box. What I wanted was when I start my application it shows something like "please select something" before I select anything. For edit ctrl box... We assigned something to the CSting variable and do UpdataData(FALSE).. I wanted to do something similar like this. Thanks again.
Member 14575556 wrote:
Yes, I've tried using SetWindowText method. It's not showing in the combo box.
It does work for me. Perhaps, you used DropdownList combo?
-
Member 14575556 wrote:
Yes, I've tried using SetWindowText method. It's not showing in the combo box.
It does work for me. Perhaps, you used DropdownList combo?
Victor Nijegorodov wrote:
Perhaps, you used DropdownList combo?
Is that an MFC control?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Victor Nijegorodov wrote:
Perhaps, you used DropdownList combo?
Is that an MFC control?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
Yes. I meant the MFC combobox with CBS_DROPDOWNLIST style.
-
Yes. I meant the MFC combobox with CBS_DROPDOWNLIST style.
Yes, I used MFC combobox with CBS_DROPDOWNLIST style.
-
Thank you. This really match with what I wanted to do. :)
-
Thank you. This really match with what I wanted to do. :)
-
Yes, I used MFC combobox with CBS_DROPDOWNLIST style.
Member 14575556 wrote:
Yes, I used MFC combobox with CBS_DROPDOWNLIST style.
Then you will only able to display a string already inserted in the combo listbox. Use either CComboBox::SelectString or CComboBox::SetCurSel.