tags:

views:

825

answers:

2

In MFC, a CListBox has a "disable no scroll" property. When you set it to true, the vertical scrollbar is always there, no matter how many items you have. How can I do the same thing with CListCtrl?

+1  A: 

The standard control does not seem to support your desired behavior.

You could either create enough entries to make the scroll bar visible or you could create your own control implementing it the way you like. Inbetween would be the ownerdrawn style, but that does not apply to the scroll bar.

BTW: what would be a reason to have the scrollbar visible all the time in a list control anyways?

HS
I'm using report view. I can set the width of the list control to the sum of my column widths, but then it's not wide enough to accommodate the scrollbar when it appears. I can make it wider, but then without the scrollbar I have an ugly grey rectangle on the end of my headings row.
Tommy Herbert
Maybe it would be easiest to dynamically adjust the column widths when the scrollbar appears? Then the next question is, how do you know when that happens?
Tommy Herbert
+1  A: 

Given you are trying to have a nice report view with columns sized to fit exactly - no horizontal scroll and no ugly grey bar in place of scroll.

From memory in the report view you can add a final column which will fill the rest of the space and cannot be sized. I cannot seem to find the appropriate code in the MSDN at the moment, recalling vaguely a size of -1 for the column.

If you where to continue to resize the columns, then I would do that when : - the app finishes adding/deleting a set of new items to the report - the user resizes the report window

Also to consider, why not let the users adjust the size of the columns to what they want?

Greg Domjan
Thanks for that, Greg. I think I have the final column by default: the ugly grey box I'm talking about is the title-less title cell for that column.I'll probably resize the columns when I go over a certain number of items, though I'll have to change that number if I ever resize the control.
Tommy Herbert
To answer your final question (with a fresh ration of 300 characters), users can drag the boundaries between columns, but can't resize the list control. If they drag columns around, any aesthetic defects become their own problem in my opinion.
Tommy Herbert