Results 1 to 8 of 8

Thread: ListBox vertical scrollbar

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2006
    Posts
    14

    ListBox vertical scrollbar

    How can I find out that ListBoxe's vertical scrollbar is visible?
    There is a property for the horizontal, but not for the vertical.

  2. #2
    Hyperactive Member Troy Lundin's Avatar
    Join Date
    May 2006
    Posts
    489

    Re: ListBox vertical scrollbar

    Well you could take the ItemHeight property, multiply it by the number of items in the listbox and if it is greater than the height of the listbox then the scrollbar would be visible.

    That was pulled out of thin air so there may be an easier way.
    Prefix has no suffix, but suffix has a prefix.

  3. #3
    Frenzied Member
    Join Date
    Jan 2001
    Posts
    1,374

    Re: ListBox vertical scrollbar

    There is a ScrollAlwaysVisible property but even if you set this to False, the vertical scroll bar will still appear if the list items take up more than the vertical space available in the list box. It will hide the vertical scroll bar if the list items take up less than the vertical space available in the list box.

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: ListBox vertical scrollbar

    If the ItemHeight property multiplied by the Items.Count property is greater than the Height property then there are too many items to display so the scroll bar must be visible.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: ListBox vertical scrollbar

    Quote Originally Posted by Troy Lundin
    Well you could take the ItemHeight property, multiply it by the number of items in the listbox and if it is greater than the height of the listbox then the scrollbar would be visible.

    That was pulled out of thin air so there may be an easier way.
    Shazzam!
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    Hyperactive Member Troy Lundin's Avatar
    Join Date
    May 2006
    Posts
    489

    Re: ListBox vertical scrollbar

    Shazzam!
    I was thinking more along the lines of deja vu.
    Prefix has no suffix, but suffix has a prefix.

  7. #7

    Thread Starter
    New Member
    Join Date
    Dec 2006
    Posts
    14

    Re: ListBox vertical scrollbar

    Can you give me code that how I can do this?

  8. #8
    Hyperactive Member Troy Lundin's Avatar
    Join Date
    May 2006
    Posts
    489

    Re: ListBox vertical scrollbar

    Are you serious? All three properties have been mentioned.

    Lb is the listbox.

    Code:
    If Lb.ItemHeight * Lb.Items.Count > lb.Height Then
        ' Scrollbar visible
    End If
    I apologize.
    Prefix has no suffix, but suffix has a prefix.

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