Panels and Graphics

N

Niels Jensen

I have a panel which uses DrawImage to paint an image that is actually
larger than the frame of the panel. But I have two problems:

1. Is there nay way to add scroll bars so that it includes the whole
image at present the only way to do this is for me to add a control in
the panel at a position out of the frames size range - the
autoscrollbars then kick in and allow me to scroll around the image.

2. When I do the above, the image is "erased" as it gets moved from the
screen. for example if I scroll down 10 pixels and then back up, the 10
pixels that used to have the image have vanished. the image seems to
only exist in the protion of the panel that was initialy visible when
the drawimage command was done.

Is there any way to have the whole image placed in the panel and then to
have scroll bars that alow me to scroll around the image?

Thanks for any help you guys can offer in advance...

Niels
 
K

Ken Tucker [MVP]

Hi,


Try something like this.

Dim bm As Bitmap

bm = Bitmap.FromFile("MyImage.bmp")

Panel1.AutoScroll = True

Panel1.AutoScrollMinSize = bm.Size

Panel1.BackgroundImage = bm



Ken

----------------------

I have a panel which uses DrawImage to paint an image that is actually
larger than the frame of the panel. But I have two problems:

1. Is there nay way to add scroll bars so that it includes the whole
image at present the only way to do this is for me to add a control in
the panel at a position out of the frames size range - the
autoscrollbars then kick in and allow me to scroll around the image.

2. When I do the above, the image is "erased" as it gets moved from the
screen. for example if I scroll down 10 pixels and then back up, the 10
pixels that used to have the image have vanished. the image seems to
only exist in the protion of the panel that was initialy visible when
the drawimage command was done.

Is there any way to have the whole image placed in the panel and then to
have scroll bars that alow me to scroll around the image?

Thanks for any help you guys can offer in advance...

Niels
 
G

Guest

Hi Ken,

Thanks Ken - the scrollbars and backgroundimage work a treat however, now I
have the problem that whenever I move the scrollbars the backgroundimage
seems to be redrawn at every pixel it moves making a big mess on the panel.

I thought it's because it's repainting every time the scrollbars move so I
tried moving the statement to the onload section of the form, but this does
the same thing and messes up my picture.

What am I doing wrong?

Niels
 
K

Ken Tucker [MVP]

Hi,

I usually place a picturebox in the panel and set the autoscroll
property to true on the panel. I make the pictureboxes size mode to
autosize. If the picture is bigger than the panel the scroll bars will
appear.


Ken
----------------------------
Hi Ken,

Thanks Ken - the scrollbars and backgroundimage work a treat however, now I
have the problem that whenever I move the scrollbars the backgroundimage
seems to be redrawn at every pixel it moves making a big mess on the panel.

I thought it's because it's repainting every time the scrollbars move so I
tried moving the statement to the onload section of the form, but this does
the same thing and messes up my picture.

What am I doing wrong?

Niels
 

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