Solved

Combo Boxes

Posted on 2004-04-03
4
513 Views
Last Modified: 2010-04-01
Two questions:

1. How do I stop listboxes in MFC automatically alphabetising the entries?

2. I've enabled V. Scrollbars, so that all entries cannot fit into the space provided. They work fine in Test Dialog, but not after being compiled, why is that? (The listbox appears normal (with all entries fitting perfectly) with faded scrollbars)

Many thanks
0
Comment
Question by:AmarjitSingh
  • 2
4 Comments
 
LVL 15

Expert Comment

by:lakshman_ce
Comment Utility
1. Right click List Box->Properties->Styles->Uncheck 'Sort'
2. Scroll bars will appear only if the list box height is not enough to show the number of entries added to it. Try to add a string in a for loop and you will be able to see the scroll bar.

-Lakshman
0
 

Author Comment

by:AmarjitSingh
Comment Utility
Thanks, that's #1 solved, but could you expand upon adding a string to a for loop. I know what you mean, say:

for(int i = 2; i > 1; i++) { //entries displayed here }

So the loop will continually run - but where would I place this code: I cannot find where the entries of the listbox are located in my source.

Cheers

0
 

Author Comment

by:AmarjitSingh
Comment Utility
Okay, I am now knowledgeable of the origin of the invisibility of the scrollbars intended to be present on the combo boxes.

As you may have awareness of, the Test Dialog's generation of the dialog is not accomplished via the usage of the MANIFEST file, which my application indisputably utilises. The MANIFEST file peculiarly has a refusal of displaying the listbox's scrollbars, despite them being strictly defined. This is the explanation for the invisibility of the scrollbars in the solution, but simultaneously the answer to the issue regarding the fact of the presence in Test Dialog.

So, in conclusion, from what has been stated above, undoubtedly, how might I able to achieve the existence of scrollbars in my listboxes, of my compiled solution, whilst concurrently retaining an inclusion of the MANIFEST file?

Thankyou
0
 
LVL 19

Accepted Solution

by:
mrwad99 earned 50 total points
Comment Utility
The test dialogue has items added to it for the purpose of displaying.  There will be no items in it in the compiled program since VC++ does not add them.  If you want items in the listbox in the compiled EXE you must add them yourself in OnInitDialog() via AddString (http://msdn.microsoft.com/library/en-us/vclib/html/_mfc_CListBox.3a3a.AddString.asp?frame=true).  This is what was mentioned earlier by lakshman_ce; the best place to do this is in a for loop for speed.

If you add enough items to the listbox you will see that the scrollbars become visible; since there is a need for them now.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

744 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

8 Experts available now in Live!

Get 1:1 Help Now