Resize without scrollbars

J

John Kraft

I have a listview control that I want the columns of to remain a
proportional size filling the listview completely. In the listview's
Resize method, I calculate the new sizes and all looks fine.
Sometimes, but not always though, scrollbars appear. The scroll bar
has nowhere to scroll (because the columns fit the listview's size
perfectly), and if you click on the scrollbars, they disappear. Anyone
know what's causing the bars to appear and how to keep the scrollbars
from appearing?

thanks,

john
 
T

thi

What scrollbar are we talking about? Horizontal or vertical. My guess is the
the column header width is longer then the listview width itself which cause
the horizontal bar to appear and that could result the vertical bar to
appear too.

Can't really tell without seeing what exactly going on.
 
J

John Kraft

What scrollbar are we talking about? Horizontal or vertical. My guess is the
the column header width is longer then the listview width itself which cause
the horizontal bar to appear and that could result the vertical bar to
appear too.

Can't really tell without seeing what exactly going on.
I'm sorry for not being specific enough. It is the horizontal scroll
bar that appears. I have calculated the width of the columns (there
are only 2 columns) like this:

col2Width = listview.Width - col1Width - 4; // 2 pixel border

This seems to work just fine most of the time; however, sometimes the
h scrollbar appears. The only time it is consistently reproducable is
when going from maximized to normalized. The rest of the times it
seems to be random, and clicking on the right scroll button causes it
to disappear. I have tried making my pixel border cushion bigger, but
that doesn't seem to effect it. It's almost as if the calculations
are not being performed each time, or the calculation is somehow
fractional and thereby rounding up. *shrug*

Thanks,

john
 
T

thi

Assuming that all the listitems in the listview not exceed the maximum item
count in the visible area of the listview i guess your code look ok. If not
that will cause the vertical scroll bar to appear and of course you will
need to recalculate the second column heard and taking into account that the
new width now should include the vertical scrollbar width. (i think it is 15
pixels)


For example: say i have a listview, width = 500, height = 500, maximum item
display in visible area: 10. Here is my code

//Assuming the columnheader[0] default = 450;
if (listview.items.count > 10)
{
//This will force the listview not to show the horizontal bar but
//still keeping vertical bar. 15 is an assumtion of the vertical bar
width.
listview.columnheader[0].width = 450 - 15;
}
else
{
listview.columnheader[0].width = 450 ;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top