How does somebody add scroll bars to a ListView?

0
0

I have a ListView inside of a panel and I want to add scroll bars to it. I was able to add scroll bars to the panel and have it scroll the ListView, but I just want to have it scroll through the rows. How do I add scroll bars to ListView that just auto scrolls through its rows. I want the scroll bars to start with the first row and not in the header. Scrollable was set to true. See the screen shot. Here is a copy of my ListView code.

private void PopulateListView(TreeNode newSelected)

{

ListView1.Items.Clear();

DirectoryInfo nodeDirInfo = (DirectoryInfo)newSelected.Tag;
ListViewItem item = null;
IndexCount = 9;
foreach (FileInfo file in nodeDirInfo.GetFiles())
{
double size;
size = file.Length / 1024;
if (size < 1)
{
size = 0;
}
   item = new ListViewItem(file.Name, 1);
   string Ext = Path.GetExtension(file.Name);
ListView1.Items.Add(item);
if (MyImageIndex(Ext) > 8)
{
imageList1.Images.Add(Image.FromFile(file.FullName));
}
item.ImageIndex = MyImageIndex(Ext);
item.SubItems.Add(size.ToString());
item.SubItems.Add(file.Extension);
item.SubItems.Add(file.LastAccessTime.ToShortDateString());
IndexCount++;
}
Reset = 0;
}

 

 

Attachment
  • You must to post comments
0
0

Cannot reproduce. See screenshot below. I simply added items to a listview. If you can reproduce in a test case please attach it. A code snippet is not enough to reproduce. The screenshot you attached is truncated, etc.

 

listview-screenshot

  • You must to post comments
0
0

The scrollbars appear automatically unless you set listView1.Scrollable to false. Making the panel scroll the listview itself will do just that. If the scrollbars don’t appear for you please attach a small sample.

  • James Nimmo
    What else do you need to see?
  • Luca (ITG)
    A small app that shows the problem. When I use a listview and add enough rows it shows the scrollbar.
  • James Nimmo
    I have added the ListView code.
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.