CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2011
    Posts
    1

    Exclamation How to use ScrollBars with Listview

    Hi friends! I need some assistance Im trying to use a Scrollbar with a listview this is my code

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace WindowsFormsApplication1
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
    listView1.Scrollable = true;
    listView1.View = View.Details;

    ListViewItem lvi = new ListViewItem("Adam");
    lvi.SubItems.Add("416-485-9654");
    listView1.Items.Add(lvi);
    }

    private void button1_Click(object sender, EventArgs e)
    {

    }
    }
    }


    so when I scroll down i see more and more of the information PLZ HELP

  2. #2
    Join Date
    May 2011
    Location
    Washington State
    Posts
    220

    Re: How to use ScrollBars with Listview

    Change your current code from what you have to this:

    Code:
    private void Form1_Load(object sender, EventArgs e)
    {
      listView1.Scrollable = true;
      listView1.View = View.Details;
    
      for (int i=0; i<250; i++)
      {
         ListViewItem lvi = new ListViewItem("Adam");
         lvi.SubItems.Add("416-485-9654");
         listView1.Items.Add(lvi);
      }
    }
    The listview will normally default to showing and enabling horizontal and verticle scroll bars... but you have to fill the list beyond it's display capacity to trigger their use.

    Best of luck!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured