By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,096 Members | 1,264 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,096 IT Pros & Developers. It's quick & easy.

view the image in VB

P: 4
Hi,

I want to view the image in my form. It relates to a combo box. Whenever i change the Form_no in the combo box. The image in the form should change accordingly. And the image viewer should have Scroll bars to view it up and down, left and right. I want to have Shortcut Keys by using Function Keys. I want to zoom in and zoom out the image to view it properly. Is it possible.

If anyone knows the answer please let me know.
Mar 26 '07 #1
Share this Question
Share on Google+
5 Replies


SammyB
Expert 100+
P: 807
Note -- All of the properties below assume that you are using VB.NET. If you are using VB6 or VBA, the property names may not be the same, but the principles are the same.

> I want to view the image in my form.
Use a PictureBox.

>Whenever i change the Form_no in the combo box. The image in the form should change accordingly
Use the PictureBox.Load method

>And the image viewer should have Scroll bars to view it up and down, left and right.
set the Form's AutoScroll property to true

>I want to have Shortcut Keys by using Function Keys
Use the form's KeyPress event & check for the function key.

>I want to zoom in and zoom out
Before you load a picture, set the PictureBox's SizeMode to AutoSize. After loading the picture, save the width & height of the PictureBox. Then to Zoom, set the SizeMode to StretchImage and change the size of the PictureBox (ie double the size for a 2X zoom). The form will automatically create scroll bars if needed (and automatically remove them if you make the form large enough)

>Is it possible.
I did it. HTH --Sam
Mar 26 '07 #2

P: 4
Hi,

Thanks for your reply. I still seen some difficulties to work on it.

My Question : And the image viewer should have Scroll bars to view it up and down, left and right.
Your Reply: set the Form's AutoScroll property to true
My Ques: I couldn't find any property based on this.

My Ques: I want to have Shortcut Keys by using Function Keys
Your Reply : Use the form's KeyPress event & check for the function key.
My Ques: I tried but i don't know how to do this.

My Ques: I want to zoom in and zoom out
Your Reply: Before you load a picture, set the PictureBox's SizeMode to AutoSize. After loading the picture, save the width & height of the PictureBox. Then to Zoom, set the SizeMode to StretchImage and change the size of the PictureBox (ie double the size for a 2X zoom). The form will automatically create scroll bars if needed (and automatically remove them if you make the form large enough)
My Ques: Still i couldn't get this.

Can you send me some example codes for me which is related to this if possible. So that i can easily got the idea. I send you the code which i did with this mail. Please check it out and alter it if there is a need.

************************************************** ***********
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. ConnString = "Provider=MSDASQL.1;Persist Security Info=False;Extended Properties=""DSN=MS Access Database;DBQ=" & App.Path & "\bckauto.mdb;DefaultDir=" & App.Path & ";DriverId=25;FIL=MS Access;"""
  3. SQLtwoString = "SELECT tblformname.Form_Name FROM tblformname;"
  4. DbAdo.Open ConnString
  5.     Set RsAdo = DbAdo.Execute(SQLtwoString)
  6.     If RsAdo.BOF = False Or RsAdo.EOF = False Then
  7.     Do While Not RsAdo.EOF
  8.         Me.Form_nobox.AddItem (RsAdo("Form_Name").Value)
  9.         RsAdo.MoveNext
  10.     Loop
  11.     End If
  12.  
  13. End Sub
  14.  
  15. Private Sub Form_nobox_LostFocus()
  16. Form_Picturebox = LoadPicture("F:\Myprojects\Automobile\Images\" & Form_nobox & ".jpg")
  17. End Sub
************************************************** *********
Mar 31 '07 #3

Expert 5K+
P: 8,434
Looks like VB6 - is that right? SammyB was talking about VB.Net, which is different in many ways.

The code looks alright - what problem do you have with it?
Apr 1 '07 #4

P: 4
Hi,

Yeah this is VB.

I need to know how to Set the Shortcut Key to zoom the image. Please provide me some example code's. Even its VB.net, its ok for me.

In that Code, i load the picture. But i don't know how to use the scroll bar inside the picture box. I can't see any options in the properties of Picture Box. The image is large in size. So we need a scroll to view it.
Apr 1 '07 #5

Expert 5K+
P: 8,434
Hi,

Yeah this is VB.

I need to know how to Set the Shortcut Key to zoom the image. Please provide me some example code's. Even its VB.net, its ok for me.

In that Code, i load the picture. But i don't know how to use the scroll bar inside the picture box. I can't see any options in the properties of Picture Box. The image is large in size. So we need a scroll to view it.
I think you can probably ignore most of what SammyB said, because (I believe) he was referring to enhanced capabilities in VB.Net.

I believe the usual technique in VB6 is to place an ImageBox control inside the picture box. Then you load your image into the ImageBox. You zoom and scroll the image by resizing and moving the ImageBox.

Have a play with it - once you've got the concept, it's actually pretty simple to set up.
Apr 1 '07 #6

Post your reply

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