CComboBox
-
Hi all, i have a combo box whose type is dropdown and i want that it should be only selectable i mean user should not be able to edit in that combo box. i tried with changing it's type to drop list by that way it becomes only selectable but i can not set the default values in that combo box if i am doing m_wndCombo.SetWindowText("Default"); in InitDialog then it does not show that "Default" string in combo box. how can i get both the feautures? means noneditable and should be able to set the default values at start of dialog!! Is it possible with combo box?? Thanks and regards Harshal
-
harsha_1234 wrote:
i tried with changing it's type to drop list by that way it becomes only selectable but i can not set the default values in that combo box
Use
SetCurSel
to set currently selected item. You cannot useSetWindowText
for this purpose. You can set the initial index of the combo box inOnInitDialog
.
Nibu thomas A Developer Programming tips[^] My site[^]
Nibu babu thomas wrote:
Maybe in OnInitDialog.
Not even there.
SetWindowText
refers to the window as a whole. I haven't tried this but in my opinion, it will not set the display value of the combobox.Nobody can give you wiser advice than yourself. - Cicero
-
Hi, Use int SetCurSel( int nSelect ); or if you already have to selecting by text from list SelectString( int nStartAfter, LPCTSTR lpszString );
----------- Mila
oh thanks but how can i do this way like if i have a dropdown combo and i want to make the edit control non editable is it possible?? actually i have used CComboBox with dropdown property every where and till now i was checking the selected text on OnOk but if now if i want that combo to be dropdown and with non editable edit control !! is it possible?? Thanks and regards Harshal
-
Nibu babu thomas wrote:
Maybe in OnInitDialog.
Not even there.
SetWindowText
refers to the window as a whole. I haven't tried this but in my opinion, it will not set the display value of the combobox.Nobody can give you wiser advice than yourself. - Cicero
brahmma wrote:
Not even there. SetWindowText refers to the window as a whole.
When did I say that? :| You should read carefully before commenting.
Nibu thomas A Developer Programming tips[^] My site[^]
-
brahmma wrote:
Not even there. SetWindowText refers to the window as a whole.
When did I say that? :| You should read carefully before commenting.
Nibu thomas A Developer Programming tips[^] My site[^]
I did not tell you said anything. I said, setwindowtext refers to the window as a whole. It is more abstract and won't set the text value of the current selected item. Your opinion was that it may work in initdialog. I said an am saying it won't even work there!
Nobody can give you wiser advice than yourself. - Cicero
-
I did not tell you said anything. I said, setwindowtext refers to the window as a whole. It is more abstract and won't set the text value of the current selected item. Your opinion was that it may work in initdialog. I said an am saying it won't even work there!
Nobody can give you wiser advice than yourself. - Cicero
brahmma wrote:
Your opinion was that it may work in initdialog.
Wrong! What I meant was that he should use
SetCurSel
inOnInitDialog
.
Nibu thomas A Developer Programming tips[^] My site[^]
-
brahmma wrote:
Your opinion was that it may work in initdialog.
Wrong! What I meant was that he should use
SetCurSel
inOnInitDialog
.
Nibu thomas A Developer Programming tips[^] My site[^]
Nibu babu thomas wrote:
Wrong! What I meant was that he should use SetCurSel in OnInitDialog.
Okay.
Nobody can give you wiser advice than yourself. - Cicero
-
oh thanks but how can i do this way like if i have a dropdown combo and i want to make the edit control non editable is it possible?? actually i have used CComboBox with dropdown property every where and till now i was checking the selected text on OnOk but if now if i want that combo to be dropdown and with non editable edit control !! is it possible?? Thanks and regards Harshal
harsha_1234 wrote:
if i have a dropdown combo and i want to make the edit control non editable is it possible??
Why on earth would you need it? Use the drop list style straight away. Handle the CBN_SELCHANGE and that will help you realise selection change in the combo box.
Nobody can give you wiser advice than yourself. - Cicero
-
oh thanks but how can i do this way like if i have a dropdown combo and i want to make the edit control non editable is it possible?? actually i have used CComboBox with dropdown property every where and till now i was checking the selected text on OnOk but if now if i want that combo to be dropdown and with non editable edit control !! is it possible?? Thanks and regards Harshal
Hi, I don't know why you insist on dropdown style - I think in your case drop list is more proper. You can try to override CBN_EDITUPDATE message: "The CBN_EDITUPDATE notification message is sent when the edit control portion of a combo box is about to display altered text. This notification message is sent after the control has formatted the text, but before it displays the text."
----------- Mila
-
Hi all, i have a combo box whose type is dropdown and i want that it should be only selectable i mean user should not be able to edit in that combo box. i tried with changing it's type to drop list by that way it becomes only selectable but i can not set the default values in that combo box if i am doing m_wndCombo.SetWindowText("Default"); in InitDialog then it does not show that "Default" string in combo box. how can i get both the feautures? means noneditable and should be able to set the default values at start of dialog!! Is it possible with combo box?? Thanks and regards Harshal
harsha_1234 wrote:
i have a combo box whose type is dropdown and i want that it should be only selectable i mean user should not be able to edit in that combo box.
You can't. By using the
CBS_DROPDOWN
orCBS_SIMPLE
style, there will be an edit control as part of the combobox. If you do not want this, you must use theCBS_DROPDOWNLIST
style instead.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb