ListView Vertical Scrollbar

Hi,

I need to have a ListView only with a Vertical Scrollbar, but i don't know how! At this moment i have a listview with the view propertie set to List ! In this listview i have only a colummn, but due to its size (listview), an horizontal scrollingbar was created

Does anyone knows how to solve this

Thanks



Answer this question

ListView Vertical Scrollbar

  • TheBlackShadow

    timg_msft wrote:

    Put your ListView in a panel at (0,0). Make the panel's width the width of your ListView control less the width of a Vertical scroll bar.

    PInvoke to GetSystemMetrics(SM_CXVSCROLL) to get the scroll bar's width.



    Hi timg_msft,

    I am very new to Pocket PC application development. Could you please elaborate on how to use the PInvoke and the entire process. Even a link of how to do it would be of great help.

    Please help.

    My original question is at:
    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=834350&SiteID=1

    Might be you can take a look at that to get a better understanding of my requirement.

    Regards,
    Suman




  • sunny123

    Great way to do it. That saved me a lot of time and effort!

    Thanks



  • Angry Coder

    I was searching for a similar thing under basic windows forms. That is, I wanted to use a ListView to create a simple single-column list with small icons. When I just did the basic things, the ListView insisted on creating a horizontally-scrolling region with multiple columns. I would imagine this is a rather common use for ListView's, so I found it rather vexing that there was no easy way to do this.

    Perhaps I was just looking in the wrong place, but I never did find an answer that was complete and correct. I'm going to go ahead and post it here, because although the answer I'm giving is not designed for the Compact Framework it's probably close to correct in that context and google et. al. will lead folks to this thread.

    The plan is to use the "Details" view, make the column headers invisible, and create a single column that is precisely the width of the list's client area minus space for the vertical scrollbar. Here's the code that does the job for me; I hope I didn't forget any other settings:

    listView1.View = View.Details;
    listView1.HeaderStyle = ColumnHeaderStyle.None;
    ColumnHeader h = new ColumnHeader();
    h.Width = listView1.ClientSize.Width - SystemInformation.VerticalScrollBarWidth;
    listView1.Columns.Add(h);
    

    I don't know whether SystemInformation is available in the compact framework or not, but this usage is nothing more than the GetSystemMetrics call described in previous posts.


  • nitinmehta

  • pershing

    Put your ListView in a panel at (0,0). Make the panel's width the width of your ListView control less the width of a Vertical scroll bar.

    PInvoke to GetSystemMetrics(SM_CXVSCROLL) to get the scroll bar's width.



  • Marzullo

    So, nobody know this
  • ListView Vertical Scrollbar