how to change picture in a picturebox
how to change picture in a picturebox
how to change picture in a picturebox
how to change picture in a picturebox
how to change picture in a picturebox
how to change picture in a picturebox how to change picture in a picturebox how to change picture in a picturebox how to change picture in a picturebox how to change picture in a picturebox how to change picture in a picturebox how to change picture in a picturebox how to change picture in a picturebox
how to change picture in a picturebox how to change picture in a picturebox
how to change picture in a picturebox
Go Back  Xtreme Visual Basic Talk > > > how to change picture in a picturebox


Reply
 
Thread Tools Display Modes
  #1  
Old 04-28-2008, 10:37 AM
nduchonova nduchonova is offline
Newcomer
 
Join Date: Apr 2008
Posts: 1
Exclamation how to change picture in a picturebox


I have a picturebox on my form, which already contains an image based on a value from the previous form. On a button click I want the image to change. I tried something like this:

PictureBox1.Image = image4
PictureBox.Refresh()

Is there some kind of method or event that changes the picture? I am hopeless....

Thanx a lot
Reply With Quote
  #2  
Old 04-29-2008, 04:06 PM
gnappi gnappi is offline
Freshman
 
Join Date: Mar 2006
Posts: 33
Default Picture box contents changing

Quote:
Originally Posted by nduchonova View Post
I have a picturebox on my form, which already contains an image based on a value from the previous form. On a button click I want the image to change. I tried something like this:

PictureBox1.Image = image4
PictureBox.Refresh()

Is there some kind of method or event that changes the picture? I am hopeless....

Thanx a lot
This is a REALLY easy way to do it, have you just tried putting one picture box in front of or on top of the other and using:

picturebox1.visible=false
picturebox2.visible=true

I use this to make 3d buttons (I rarely use the button control anymore) appear latched down, and have a fluorescent colored font on them when active.


Regards,

Gary
Reply With Quote
  #3  
Old 04-29-2008, 04:12 PM
optox's Avatar
optox optox is offline
Freshman
 
Join Date: Mar 2008
Posts: 49
Default

well, you can do it that way, but another way is to change the image location property of the picbox:
picbox1.imagelocation = "\your file\ picture.gif"
of course the only problem is that if you give the program to someone else and they do not have that picture it will not show.
a way to get around this is to enter a web site name like photobucket.com which stores photos for you.
picbox1.imagelocation = "photobucket.com/username/album/picture.gif"
just make a user name on photobucket or some other website like it.
Reply With Quote
  #4  
Old 05-20-2008, 11:45 AM
gnappi gnappi is offline
Freshman
 
Join Date: Mar 2006
Posts: 33
Default Another way?

Quote:
Originally Posted by optox View Post
well, you can do it that way, but another way is to change the image location property of the picbox:
picbox1.imagelocation = "\your file\ picture.gif"
of course the only problem is that if you give the program to someone else and they do not have that picture it will not show.
a way to get around this is to enter a web site name like photobucket.com which stores photos for you.
picbox1.imagelocation = "photobucket.com/username/album/picture.gif"
just make a user name on photobucket or some other website like it.

Of course the other drawback is that you HAVE to be connected to the internet.

I have to ask why use code that has two drawbacks while embedding the image has what, a minor file size issue that even storing them locally or remotely has the same issue in another fashion?





Gary
Reply With Quote
  #5  
Old 05-20-2008, 12:56 PM
AtmaWeapon's Avatar
AtmaWeaponhow to change picture in a picturebox AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

I'm not sure why this has generated so much discussion; I just tried the following:
Code:
    Dim _image1 As Image
    Dim _image2 As Image
    Dim _imageToggle As Boolean

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If _imageToggle Then
            PictureBox1.Image = _image1
        Else
            PictureBox1.Image = _image2
        End If

        _imageToggle = Not _imageToggle
    End Sub
It works perfectly, so long as you provide images for _image1 and _image2 somewhere else. Since this is pretty much what the original poster was doing, I believe the problem is probably something else.

nduchonova, you never really stated your problem, you just said "I'm trying to do something, here's the code I'm using". Could you provide more details?
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
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
how to change picture in a picturebox
how to change picture in a picturebox
how to change picture in a picturebox how to change picture in a picturebox
how to change picture in a picturebox
how to change picture in a picturebox
how to change picture in a picturebox how to change picture in a picturebox how to change picture in a picturebox how to change picture in a picturebox how to change picture in a picturebox how to change picture in a picturebox how to change picture in a picturebox
how to change picture in a picturebox
how to change picture in a picturebox
 
how to change picture in a picturebox
how to change picture in a picturebox
 
-->