Solved

CComboBox SetwindowText() with CBS_DROPDOWNLIST style

Posted on 2004-09-22
10
2,250 Views
Last Modified: 2013-11-20
I am trying to use a CComboBox in my application that has a style of CBS_DROPDOWNLIST so the user cannot type his own text in.  However, if there is not a selection (like when the application first comes up) I want the edit section to have the decscription of what is in the box.  I have tried calling SetWindowText() but it doesn't work.  I am assuming because the text I want to set is not found in the combobox droplist.  Is there a way to accomplish this with the MFC CComboBox???

Thanks,
Jedimaster
0
Comment
Question by:Jedimaster
  • 5
  • 3
10 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12123587
I guess there is not, but you don't have to do this, just create a new item with description, there are many ways to detect that the combobox remains "unselected" (actually is selected item 0)
0
 

Author Comment

by:Jedimaster
ID: 12125643
Putting the description in the droplist was my first idea but unfortunatly the powers that be do not like this option... so I have to find another way to accomplish this.
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12125724
You can put description in a static text besides or above combobox
0
 

Author Comment

by:Jedimaster
ID: 12125742
Unfortunatly I don't have room on my interface to place a label for this combo....
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12125758
What about a tooltip?
0
 

Author Comment

by:Jedimaster
ID: 12125840
nope....

listen... I appreciate your comments but I need to know if there is a way to make the CComboBox do what I need it to do.  If the standard MFC CComboBox will not work for what I need it to do, then I will have to create my own ComboBox that will.  I was just hoping that I was doing something wrong or maybe someone knew about a quirky little hack to force the CComboBox to do what I want.

Again.. no offense.... I just already have a vision of how this interface should look and react.



Thanks,
Jedimaster
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12125902
>If the standard MFC CComboBox will not work for what I need it to do, then I will have to create my own ComboBox that will.
As far as I know is your unique solution. A posible method is to make a CComboBox derived with DROP-DOWN option, and avoid any user input in the edit area.
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 250 total points
ID: 12125924
Also you can do this. Use a standard CComboBox with DROP-LIST attribute, as I suggested early, with a first "dummy" item showing some explanation. When you detect that user have selected an option, you can delete first item.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now