Scrollbars on User Controls

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?
 
C

Charlie Brown

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.
 
K

Kevin Spencer

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.
 
C

Charlie Brown

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
 

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