PictureBox on a Panel -- display scrollbars for large pics?

  • Thread starter Thread starter Rich P
  • Start date Start date
R

Rich P

I have a PictureBox on a panel on a form. I have set the form's
autoscroll = true and I have set the panel's autoscroll = true. I cycle
through a list of pictures which display in the PictureBox, but when I
show a picture which is larger than the current panel size I need to
display scroll bars. But no scrollbars display. How do I make the
panel scrollbars display when I reach an oversized picture?

PictureBox sizemode = Normal, docking in panel is set to fill.

Thanks

Rich
 
I tried setting the sizemode of the picturebox to "autosize", but then I
got an crossthread error message -- I am running the viewer in a while
loop and using a backgroundworker. Here is the error I get when I try
to use autosize on the picturebox sizemode

Cross-thread operation not valid: Control 'picImage' accessed from a
thread other than the thread it was created on.

In the error message it gave a link on how to work with cross threading
-- the article suggests to use a background work. I am already using a
background worker.


Rich
 
I fixed the crossthread error by moving the picturebox loading from
BackgroundWorkder_DoWork to BackgroundWorker_ProgressChanged(...). Now
I can at least use the AutoSize mode of the picture box, but still no
scroll bars. I need scrollbars (more than I need a cow bell :).

Rich
 
Yay! I got my dumb scrollbars! Here is what I did - I deleted the
original picturebox, deleted the containing panel, readded the panel and
dock = fill (under another panel, set autoscroll=true. Re-add a
picturebox, set sizemode to autosize, not docked, positioned at top left
cornver of containing panel. Now my oversized pictures activate the
scrollbars.

My next challenge will be dragging an oversized picture around inside
the panel.

Rich
 
Yay!  I got my dumb scrollbars!  Here is what I did - I deleted the
original picturebox, deleted the containing panel, readded the panel and
dock = fill (under another panel, set autoscroll=true.  Re-add a
picturebox, set sizemode to autosize, not docked, positioned at top left
cornver of containing panel.  Now my oversized pictures activate the
scrollbars.

My next challenge will be dragging an oversized picture around inside
the panel.

I am curious, are the scrollbars part of the Panel control or the
PictureBox control?
 
I am curious, are the scrollbars part of the Panel control or the
PictureBox control?
<<

They are part of the panel. The picturebox doesn't have scrollbars
built-in.

Rich
 
Back
Top