Panel Autoscroll

Y

YYZ

I discovered something very interesting today, and it will save me a
bunch of time...maybe.

If you set Panel1.Autoscroll to true, and have a panel2 inside of it, I
can add all sorts of controls at runtime, and panel1 will develop
scrollbars to take all of this into account. Except for 1 little
really annoying feature.

When it displays vertical scrollbar (which is good), that space that is
taken up by the vertical scrollbar now makes the panel think that it
needs a horizontal scrollbar, too.

I have code that resizes panel2 to be the same width as panel1, and
that is the problem. Anyone know of a way to find out if panel1 has a
vertical scrollbar, and if so, figure out the width of it, so that I
can decrease the size of panel2 to take this into account and then the
panel won't display a horizontal scrollbar as well?

Did that make sense? Anyone have any ideas for me?

Matt
 
C

Chris

YYZ said:
I discovered something very interesting today, and it will save me a
bunch of time...maybe.

If you set Panel1.Autoscroll to true, and have a panel2 inside of it, I
can add all sorts of controls at runtime, and panel1 will develop
scrollbars to take all of this into account. Except for 1 little
really annoying feature.

When it displays vertical scrollbar (which is good), that space that is
taken up by the vertical scrollbar now makes the panel think that it
needs a horizontal scrollbar, too.

I have code that resizes panel2 to be the same width as panel1, and
that is the problem. Anyone know of a way to find out if panel1 has a
vertical scrollbar, and if so, figure out the width of it, so that I
can decrease the size of panel2 to take this into account and then the
panel won't display a horizontal scrollbar as well?

Did that make sense? Anyone have any ideas for me?

Matt

I do this in a datagrid to remove the scroll bar. Don't know but maybe
it'll work for your panel.

Call it by doing:
DisableScrollBars(Panel1.Controls)


Public Sub DisableScrollBars(ByRef Controls As
Windows.Forms.Control.ControlCollection)
For Each c As Windows.Forms.Control In Controls
If TypeOf c Is Windows.Forms.ScrollBar Then
If TypeOf c Is Windows.Forms.HScrollBar Then
c.Height = 0
ElseIf TypeOf c Is Windows.Forms.VScrollBar Then
c.Width = 0
End If
End If
Next
End Sub


Hope it helps
Chris
 
Y

YYZ

Thanks for the suggestion, Chris, but unfortunately, the panel doesn't
report the scrollbar as a member of the controls collection -- just one
control in the collection, and that was panel2.

Thanks anyway.

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top