none
Win API ListView Scrolling doesn't display all items RRS feed

  • General discussion

  • I have a ListView on a Visaul Studio Project that works fine when I have both horizontal and vertical scroll bars enabled.  I only needed the Verticle Scroll Bar enables and had to send a message to the window handle to turn on the verticle scroll bars.  When I do this I have 180 items in the listview but I'm only able to see the first 107 items. the height of the Listview is set so I see 10 items at one time.  I don't have any groups set and turned ShowGroups to off.  The scroll bar only works by dragging and nothing happens if I try to use the mouse to scroll down one screen at a time.

     When I comment out the code below I get all 180 items.  My form look silly with a horizontal scroll bar that does nothing.  How do I get all the items to appear with only the verticle scroll bar.  I tried using the PageUp and PageDown to view the rest of the items but it didn't work.

            [DllImport("user32.dll")]
            static public extern bool ShowScrollBar(System.IntPtr hWnd, int wBar, bool bShow);

            int SB_VERT = 1;


            //call user32.dll function to turn on vertical scroll bar.
            ShowScrollBar(MathConstantsForm.Handle, (int)SB_VERT, true);


    jdweng

    Thursday, May 17, 2012 3:55 PM

All replies

  • Use an external scroll bar.  That is place a stand alone scroll bar to the right of the list view.

    Thursday, May 17, 2012 5:20 PM
  • How do you bind it to the DataGridview.  I added the control manually from the control tool box.  I couldn't find an example of the code needed.


    jdweng

    Thursday, May 17, 2012 6:57 PM
  • How do you bind it to the DataGridview.  I added the control manually from the control tool box.  I couldn't find an example of the code needed.


    jdweng


    How did we get from a ListView to a DataGridView?  My response was for a ListView.
    Thursday, May 17, 2012 7:04 PM
  • It is a ListView.  I have both on the forms and wasn't thinking.

    jdweng

    Thursday, May 17, 2012 7:07 PM