Detecting the appearance of a scrollbar in a listview

G

Guest

I have a listviw with the column default widths adjusted to fill the entire
width without any scroll bars. If there are enough items added to the list
that a vertical scroll bar is added I'd like to narrow the last column to
avoid the creation of an Hscroll as well. I'm not sure how to tell if the
addition of annother item will extend the length of the list beyond the
hieght of the control though.
 
T

Tim Wilson

Insert the following code after the code that you use to add or remove items
from the ListView.

if (this.listView1.Columns.Count > 0)
{
this.listView1.Columns[this.listView1.Columns.Count - 1].Width = -2;
}
 

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