Solved

CComboBox SetwindowText() with CBS_DROPDOWNLIST style

Posted on 2004-09-22
10
2,301 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:Jedimaster
ID: 12125742
Unfortunatly I don't have room on my interface to place a label for this combo....
0
 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Replacement selected text 2 63
List out all word 7 316
EvenOdd challenge 10 125
sumHeights  challenge 17 74
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

840 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