• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 565
  • Last Modified:

Combo Boxes

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
AmarjitSingh
Asked:
AmarjitSingh
  • 2
1 Solution
 
lakshman_ceCommented:
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
 
AmarjitSinghAuthor Commented:
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
 
AmarjitSinghAuthor Commented:
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
 
mrwad99Commented:
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now