473,785 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do i Set an autosize(or auto fit)an image into the picturebox

1 New Member
Hello,

I am putting together a simple picture viewing program to view jpg pictures. I have the picturebox autosize set to true. I dont have the
picturebox in a pannel set to autoscroll, so if I get a picture that is
larger than the width/height of the containing form (pannel, etc) I can't able to
scroll. When I open this pic in Microsoft Photo Editor - it
opens to 50% zoom by default. How can I set the zoom in my picturebox which
is set to autosize? How do I set the zoom? Like if I get the image size say
1900x800 I will automatically zoom the image to 50%. How do I set the zoom
of the image? I tried Img.Zoom, but there is no .Zoom.

Thanks,
Dravid.
Jun 27 '07 #1
2 7838
kadghar
1,295 Recognized Expert Top Contributor
i think you can use PictureSizeMode ;
e.g.

Image1.PictureS izeMode = 1

If you set it to 0 I'll put the picture in its original size even if it doesnt fit in your Image (wont show the complete picture)

If you set it to 1 it'll strech to fit your image

if you set it to 2 i'll zoom <--- i think this is the one you need.

(I dont have VB here, only VBA so i dont remember if this applies to for a picture box, but you can always use an Image)

Good Luck
Kad
Jun 27 '07 #2
I noted it from a forum and found it working as my requirement
Expand|Select|Wrap|Line Numbers
  1. 'Picture1.Picture = Image1(1).Picture
  2.     Picture1.ScaleMode = 3
  3.     Picture1.AutoRedraw = True
  4.     Picture1.PaintPicture Picture1.Picture, _
  5.         0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight, _
  6.         0, 0, _
  7.         Picture1.Picture.Width / 26.46, _
  8.         Picture1.Picture.Height / 26.46
  9.     Picture1.Picture = Picture1.Image
Oct 7 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2023
by: Harvey | last post by:
Hello: I am trying to use Autosize=true on a long string and it extends off of my form, rather than increasing the number of lines of the Label as the documentation says it should do. Would anyone know what other property I need to set to get this to work properly? I have looked through them all and cant find any. PreferredHeight is read only.
2
5491
by: Jake | last post by:
Hi, I have a page with a bunch of thumbnails that when clicked, open the full size image in a new window. They are all different sizes and its a bit unprofessional looking. I'd like to find a component or script that will detect the size of the linked image and create a popup correctly sized to the image. Would have no toolbar, buttons,scrolling, etc. Just a clean, correctly sized window. Any way to do this?
2
3813
by: Tim Wallace | last post by:
I'm using Visual Studio 2003. Is there a way one can cause columns in a DataGrid to autosize? Also, is there a way to cause the last column to take up the remaining space between the end of the column and the right edge of the DataGrid? And finally, is there a way to remove the row that permits a user to add data? I looked in the Help, but was unable to discern the answers to the aforementioned questions. Tim
9
10392
by: Kevin Westhead | last post by:
Can anyone confirm whether or not there are any limits imposed on the widths of autosized columns in a list-view. I've found that the autosizing appears to have an upper limit, i.e. it will not expand beyond some (unknown) maximum length. This applies to user-autosizing (double-clicking the divider) and code-autosizing using LVSCW_AUTOSIZE. For example, create a new project and place a ListView (VB5 version) and CommandButton on a form...
7
2624
by: Georges Bessis | last post by:
The image I set as background are left at original size. In a picturebox, I can decide to strech the image. Can I do that to fill my background ? Regards GB
3
4093
by: tedqn | last post by:
I'm using VS 2005. When user selects a image from the FileListBox, the code is PictureBox.ImageLocation = sFullPath PictureBox is set to AutoSize. When the newly loaded image is smaller than the panel size, I want to center it within the panel by calculating and move the box to a location other than (0,0). The
1
7830
by: Nathan Laff | last post by:
I have a panel that I want to AutoSize with an AutoSize mode of GrowAndShrink, but I only want it to autosize vertically. Reason being I have anchors set up to a usercontrol which can resize. Any idea on how to accomplish that?
2
2541
by: ChrisNightingale | last post by:
Hi everybody, I have an odd issue which I'm not sure how to resolve. I'm basically implementing a print mechanism which takes a series of controls and reproduces them on a print document. So what I'm trying to do is print out a label so what I basically did is use Graphics.DrawString passing in the text of the label, the font of the label and the rectangle which represents the label (because it's set to autosize this should be the right...
2
1613
by: Joe Cool | last post by:
I am trying to display several images on a standard Windows Form. Each image is displayed in a PictureBox control that is 180,130 in size. I get the Primary Screen size to determine how many images will on one line of images. I have a form boolean variable that I set to true in the ClientSizedChanged event handler. In the loop where I am displaying the images, I check this boolean, and if true, I set the Y coordinate loop counter to the...
0
10148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.