changing image in picture box by clicking image
changing image in picture box by clicking image
changing image in picture box by clicking image
changing image in picture box by clicking image
changing image in picture box by clicking image
changing image in picture box by clicking image changing image in picture box by clicking image changing image in picture box by clicking image changing image in picture box by clicking image changing image in picture box by clicking image changing image in picture box by clicking image changing image in picture box by clicking image changing image in picture box by clicking image
changing image in picture box by clicking image changing image in picture box by clicking image
changing image in picture box by clicking image
Go Back  Xtreme Visual Basic Talk > > > changing image in picture box by clicking image


Reply
 
Thread Tools Display Modes
  #1  
Old 09-24-2014, 09:37 AM
FireSlade FireSlade is offline
Newcomer
 
Join Date: Sep 2014
Posts: 3
Question changing image in picture box by clicking image


Hey everyone, I've been searching through the forum trying to find a solution to this problem, and I've seen some similar issues, but not exactly what I need an answer to.

I'm trying to get an image in a picture box to toggle between a large and small version of the same image. I've made 2 picture boxes and overlapped the smaller one on top of the large one. The large picture box visible is set true and small is set false. I can't figure out the code that will allow me to swap those properties, by clicking on the image, so that the small picture becomes true and is visible and the large picture becomes false. This is the code I put for the large picture box:

Private Sub CDPictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LargePictureBox.Click
' Large CD image

LargePictureBox.Image = My.Resources.CDROM01
LargePictureBox.Visible = True
SmallPictureBox.Visible = False

End Sub

Small:

Private Sub SmallPictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SmallPictureBox.Click
' Small CD Image

SmallPictureBox.Image = My.Resources.CDROM01
SmallPictureBox.Visible = True
LargePictureBox.Visible = False

End Sub

I know there's probably a very simple solution to this that I'm completely overlooking, but I just can't get it. Any help would be greatly appreciated. Thanks.
Reply With Quote
  #2  
Old 09-24-2014, 09:54 AM
passel's Avatar
passelchanging image in picture box by clicking image passel is offline
Sinecure Expert

Super Moderator
* Guru *
 
Join Date: Jun 2003
Location: Upstate New York, usa
Posts: 8,015
Default

You have which picturebox you show reversed.
You can only click on a visible box, so that is the one you want to hide, and show the other.

LargeClick
small.visible

SmallClick
LargeVisible

You shouldn't have to assign the image in each click even.
Just load the image in each picturebox in the Form's Load event.

In Fact, you are loading the image twice in memory, but you could just load it once, and have both pictureboxes reference the same image.

Code:
'In the Form load event
LargePictureBox.Image = My.Resource.CDROM01
SmallPictureBox.Image = LargePictureBox.Image

Private Sub CDPictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LargePictureBox.Click
  LargePictureBox.Visible = False
  SmallPictureBox.Visible = True
End Sub

Private Sub SmallPictureBox_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SmallPictureBox.Click
  SmallPictureBox.Visible = False  
  LargePictureBox.Visible = True
End Sub
I assume you have the SizeMode of the pictureboxes set to Stretch or Zoom, and they are different size pictureboxes.
__________________
There Is An Island Of Opportunity In The Middle of Every Difficulty.
Miss That, Though, And You're Pretty Much Doomed.
Reply With Quote
  #3  
Old 09-24-2014, 10:13 AM
FireSlade FireSlade is offline
Newcomer
 
Join Date: Sep 2014
Posts: 3
Default

Thank you so much for that information. I had no idea I could just load that image once, as you instructed. Your assumptions were correct, and your corrections worked perfectly. Thanks again.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
changing image in picture box by clicking image
changing image in picture box by clicking image
changing image in picture box by clicking image changing image in picture box by clicking image
changing image in picture box by clicking image
changing image in picture box by clicking image
changing image in picture box by clicking image changing image in picture box by clicking image changing image in picture box by clicking image changing image in picture box by clicking image changing image in picture box by clicking image changing image in picture box by clicking image changing image in picture box by clicking image
changing image in picture box by clicking image
changing image in picture box by clicking image
 
changing image in picture box by clicking image
changing image in picture box by clicking image
 
-->