Scrollbars on User Controls

  • Thread starter Thread starter Charlie Brown
  • Start date Start date
C

Charlie Brown

I have a user control where I override the paint event and draw the
control myself. When I sraw outside of the visible area, I need the
scrollbars to appear and allow the user to scroll the painted area into
view. I can enable and show the scrollbars, but they dont allow
scrolling... What am I missing on this one?
 
Took a shot at that one as well, no go. Also tried setting the size to
something and the clientsize to something bigger, but nothing happened
there as well.
 
First, you have to put the UserControl inside another Control, such as a
Panel, that will serve as the Viewport/Container. Second, you set AutoScroll
to true. Third, you must resize the UserControl so that at least one of its
dimensions exceeds the corresponding dimenstion of the Viewport. And Bob's
your Uncle.

--
HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

I just flew in from Chicago with
a man with a wooden leg named Smith
who shot an elephant in my pajamas.
So I bit him.
 
Works well Kevin. Any thoughts on how to do this in code instead of
dropping a control into a container, but actually writing the
scrollbars into your own control.
I tried inheriting a ListView control, but when you set OwnerDraw =
True, the scrollbars need to be handled in the code. unfortunatley I
can't find any code examples anywhere
 
Back
Top