Results 1 to 6 of 6

Thread: [2008] Resizing a panel to accomodate scrollbars.

  1. #1

    Thread Starter
    Hyperactive Member Troy Lundin's Avatar
    Join Date
    May 2006
    Posts
    489

    [2008] Resizing a panel to accomodate scrollbars.

    This is silly and I should be able to figure it out.

    I have a panel that is occupied by Form objects on demand. I would like the panel's width to match that of the occupying Form. The height of the panel should not change, however.

    My problem is here.

    When the Form is taller than the panel, scrollbars will appear. This is fine, I want the vertical scrollbar so that the entire Form may be viewed. The problem is; since the vertical scrollbar appears over the Form, the panel adds a horizontal scrollbar so that one may see the portion of the Form that the vertical scrollbar has overlapped.

    Is there a way to counter this effect? As in, automatically resizing the width of the panel to accomodate the space the vertical scrollbar takes.

    I have been at this for around 40 minutes and feel I am running myself in circles. Thanks for any help supplied.
    Prefix has no suffix, but suffix has a prefix.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2008] Resizing a panel to accomodate scrollbars.

    You can set the panel.width property = yourform.width + 20 or something like that, before adding the form to your panel.
    Code:
    If yourform.height >= Panel1.Height Then
       Panel1.Width = yourform.width + 20
    End If
       Panel1.controls.add(yourform)

  3. #3

    Thread Starter
    Hyperactive Member Troy Lundin's Avatar
    Join Date
    May 2006
    Posts
    489

    Re: [2008] Resizing a panel to accomodate scrollbars.

    Is the '+20' supposed to be the width of the scrollbar? Is there a way to find the width of the scrollbar?
    Prefix has no suffix, but suffix has a prefix.

  4. #4
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2008] Resizing a panel to accomodate scrollbars.

    Yes, the default width of a scrollbar is 20 pixels. There's no direct way of getting the width of a scrollbar that I know of besides trial and error.

  5. #5

    Thread Starter
    Hyperactive Member Troy Lundin's Avatar
    Join Date
    May 2006
    Posts
    489

    Re: [2008] Resizing a panel to accomodate scrollbars.

    Ok. How would I determine if the scrollbar is visible. I cannot use Panel1.ScrollStateVScrollVisible because that would be too easy. VB doesn't like it. What should I use?
    Prefix has no suffix, but suffix has a prefix.

  6. #6
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [2008] Resizing a panel to accomodate scrollbars.

    Quote Originally Posted by Troy Lundin
    Ok. How would I determine if the scrollbar is visible. I cannot use Panel1.ScrollStateVScrollVisible because that would be too easy. VB doesn't like it. What should I use?
    The VScroll property of a panel returns a boolean value indicating whether the vertical scrollbar is visible or not.

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