vb.net - Vertical & Horizontal scrollbars in a panel -


scenario:

  • put panel on form.
  • set panel's borderstyle fixedsingle. (just can see when run it.)
  • set panel's autoscroll=true
  • set panel's anchor top, left, bottom, right
  • inside panel, place sizable control (button, picturebox or whatever).
  • adjust control's bottom edge few pixels above bottom of panel.
  • adjust control's right edge should few pixels more narrow panel minus width of vertical scrollbar. (that is, should narrow enough leave room vertical scrollbar may appear.)

now run it, , vertically resize form little shorter you'd expect vertical scrollbar appear.

problem: both scrollbars appear, because existence of vertical scrollbar reduces width of client area, forcing horizontal scrollbar appear.

apparently .net evaluates whether vertical scrollbar necessary first, evaluates whether horizontal should appear, dependent upon whether client size reduced presence of vertical scxrollbar. (i.e. same experiment doesn't cause unnecessary vertical scrollbars appear... horizontal ones.)

i'm using vb2008 express i'm guessing carries on later versions.

the solution need: need either of: a) "vertical autoscroll only" panel. b) need way tell panel "rethink" whether horizontal scrollbar necessary. (refreshes don't seem it.)

i ran sounds describe. wanted vertical scroll because going contain many many things eventually, not horizontal scroll. used table layout panel; set panel's vertical size vscroll shows; set width accommodate go in there plus whatever margin or gutter code use.

then, in tablelayoutpanel set width of scrolling panel's absolute (i used 2 pixels more panel.width). if/when user resizes, size gets distributed else. dont let scrolling panel's width change. might have to/want set minimum form size too.

the things adding same width, if yours vary, might have set accommodate widest.

not sure if encountering same thing, sure sounds it.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -