473,320 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

PictureBox with scroll bar control

I have been researching this issue and have come across a number of
solutions apparently written for VB5 or 6 and don't work under .NET,
yes folks that is progress!

Someone in this ng suggested just drop your picturebox into a panel
with autoscroll=TRUE.

I am wondering if this will work for my desired application - see
details.

I have a fixed size dialog with a fixed size window for showing
graphics. This means that my form will never get resized so as to
impinge on the picturebox (this is apparently how some of the demos I
tried worked).

For starters I would like to fit the loaded images horizontally or
vertically so as to only have 1 scrollbar at a time. So I would scale
my imagefromfile to match the panel size on one axis. If the
picturebox thus sized turns out to be larger than the panel it's
sitting in, then I presume scrollbars are shown and scrolling enabled?

I've been spending way too much time on this - thought it would be
simple, and maybe it is!

Thanks,

Gary

Dec 8 '05 #1
4 12879
Hi,

<mi*********@yahoo.com> schrieb:
I have a fixed size dialog with a fixed size window for showing
graphics. This means that my form will never get resized so as to
impinge on the picturebox (this is apparently how some of the demos I
tried worked).

For starters I would like to fit the loaded images horizontally or
vertically so as to only have 1 scrollbar at a time. So I would scale
my imagefromfile to match the panel size on one axis.
Check out the picturebox' 'SizeMode' property.
If the picturebox thus sized turns out to be larger than the panel it's
sitting in, then I presume scrollbars are shown and scrolling enabled?


Yes, that should work.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Dec 8 '05 #2
Herfried K. Wagner [MVP] wrote:

Check out the picturebox' 'SizeMode' property.


OK, I would use the (I think) 3rd option which just keeps the image at
a fixed size to be determined by the program (e.g. the Image width
would be scaled to match the panel's width, then the image could scroll
up and down - if Portrait oriented)

How do I accomplish this scaling? Do I need an intermediate image
object?

i.e. load image from file to 1 image then scale that image onto the
picturebox within the panel? Or can I do it directly as I load the
image?

As you can tell I really don't know much about this.

Thanks,

Gary

Dec 9 '05 #3
<mi*********@yahoo.com> schrieb:
Check out the picturebox' 'SizeMode' property.


OK, I would use the (I think) 3rd option which just keeps the image at
a fixed size to be determined by the program (e.g. the Image width
would be scaled to match the panel's width, then the image could scroll
up and down - if Portrait oriented)

How do I accomplish this scaling? Do I need an intermediate image
object?

i.e. load image from file to 1 image then scale that image onto the
picturebox within the panel? Or can I do it directly as I load the
image?


Add a panel control to the form and a picturebox control to the panel
control:

\\\
Me.Panel1.AutoScroll = True
With Me.PictureBox1
.SizeMode = PictureBoxSizeMode.StretchImage
Dim img As Image = Image.FromFile("C:\WINDOWS\winnt.bmp")
.Height = img.Height * Me.Panel1.ClientSize.Width / img.Width
.Width = Me.Panel1.ClientSize.Width
If Me.Panel1.ClientSize.Height > img.Height Then
.Width -= SystemInformation.VerticalScrollBarWidth
End If
.Image = img
End With
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 9 '05 #4
Herfried K. Wagner [MVP] wrote:
Add a panel control to the form and a picturebox control to the panel
control:

\\\
Me.Panel1.AutoScroll = True
With Me.PictureBox1
.SizeMode = PictureBoxSizeMode.StretchImage
Dim img As Image = Image.FromFile("C:\WINDOWS\winnt.bmp")
.Height = img.Height * Me.Panel1.ClientSize.Width / img.Width
.Width = Me.Panel1.ClientSize.Width
If Me.Panel1.ClientSize.Height > img.Height Then
.Width -= SystemInformation.VerticalScrollBarWidth
End If
.Image = img
End With


Thank you very much! By changing ">" to "<" on the comparison line I
got it to work perfectly!

Dec 10 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott M | last post by:
Hi, I am writing a small game that is using a form 800 * 600. The form can be scrolled vertically up to a height of 1200 (basically the form can be scrolled down one screen vertically). The...
0
by: Paul Loveless | last post by:
Hi all. I have a user control that contains a picturebox within a panel with the panel set to autoscroll the picturebox. One thing that I have noticed with the default functionality is when you...
5
by: Sharon | last post by:
I’m writing a Windows application. In the form I have a Panel and inside the panel I have a PictureBox control. I’m loading the PictureBox control with BMP image that has the following...
4
by: MJ | last post by:
as topic, anyone can provide some codes that enable a scroll bar to a picturebox when the picture expand?
5
by: Christopher Kurtis Koeber | last post by:
Dear All, This may sound like an elementary question but how do you implement scrollbars for the Picturebox control. Do I have to create my own code to do this or is there some property that I can...
4
by: Thiru .Net | last post by:
hi wagner, i have a doubt in panel control in windows application. i have a panel control wherein i have put a picturebox control. i show picture into picturbox control. now i need to zoom in...
3
by: jediknight | last post by:
Hi, I have a scrollable view which contains a picturebox. I need to get the location of the top let hand corner of the view so I can draw an icon. When the picturebox is scrolled vertically I...
1
by: ebiweb | last post by:
hi all, how can i control the position of vertical or horizontal scrollbals of a picture box. i load a picture in a picturebox , by default the vertical of scroll bar is at position 0 ; ...
0
by: swagatikasahoo | last post by:
how to display all lines if i will scroll the picturebox. hi, ok i m sending the code. ****************************************************** Private Sub PictureBox1_Paint(ByVal sender As Object,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.