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

Home Posts Topics Members FAQ

Button1_Click Change image in PictureBox1

How can i make a button click change an image in a picture box? I basically
have an image in my main Form, i want it to change when a button is clicked.

--
<XML>
<BEGIN:: DCSE-TRAINING>
<END:: DCSE-TRAINING>
<BEGIN:: GOOD-CAREER>
<BEGIN:: GOOD-CAREER>
<I SAID BEGIN:: GOOD-CAREER>
<BEGIN:: METHOD:: GIVE-UP>
</XML>
Nov 21 '05 #1
3 11948
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
PictureBox1.Ima ge = New
System.Drawing. Bitmap("C:\wind ows\mypicture.b mp")
End Sub

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
"NeverwaY" <ne******@hotma il.com> escribió en el mensaje
news:D4******** *************** ***********@mic rosoft.com...
How can i make a button click change an image in a picture box? I
basically
have an image in my main Form, i want it to change when a button is
clicked.

Nov 21 '05 #2
"NeverwaY" <ne******@hotma il.com> schrieb:
How can i make a button click change an image in a picture box? I
basically
have an image in my main Form, i want it to change when a button is
clicked.


\\\
Dim OldImage As Image = Me.PictureBox1. Image
Me.PictureBox1. Image = Image.FromFile( "C:\foo.bmp ")
OldImage.Dispos e()
///

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

Nov 21 '05 #3
Thanks tons, fellows! Now...is there any way to load a file from within the
project? ie: not from an external source?
--
<XML>
<BEGIN:: DCSE-TRAINING>
<END:: DCSE-TRAINING>
<BEGIN:: GOOD-CAREER>
<BEGIN:: GOOD-CAREER>
<I SAID BEGIN:: GOOD-CAREER>
<BEGIN:: METHOD:: GIVE-UP>
</XML>
"Herfried K. Wagner [MVP]" wrote:
"NeverwaY" <ne******@hotma il.com> schrieb:
How can i make a button click change an image in a picture box? I
basically
have an image in my main Form, i want it to change when a button is
clicked.


\\\
Dim OldImage As Image = Me.PictureBox1. Image
Me.PictureBox1. Image = Image.FromFile( "C:\foo.bmp ")
OldImage.Dispos e()
///

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

Nov 21 '05 #4

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

Similar topics

2
12407
by: Bill N. | last post by:
Using VB .Net 2003 Standard Edition. This simple form has a "File in Use" problem while the executable is running. Created this simple program to make sure that I hadn't done something in my code in the "real" project. In the "real" project, One part of the program saves multiple images and another part of the program moves the images to the appropriate directories based on user feedback.
3
1955
by: Li Weng | last post by:
Hi, I have a form with a picturebox. I added an image in picturebox at design time. I create the form in codes with New and .Show() to pop up. But image doesn't show up. The picturebox looks transparent. Please help. Thanks in advance. Li
0
1348
by: jez | last post by:
I'm programming in C# for a PPC, and trying to display an image from the start, i.e. as soon as the program launches. I've tried (as explained in Microsoft's .NET Compact Framework book) to use two different methods to display an image on the PDA. They work fine, but I need to click a button first (for example a radio button) for the image to display. I'd simply like to show the image as soon as the program starts. If I use the following...
4
8057
by: MAY | last post by:
Hi, I drew some lines on a form and i want convert these lines into a bitmap. How can i do that? MAY
1
3646
by: Novice | last post by:
I'm afraid I will incur the wraith of Mr. Powell on this one - but I did read his #1 FAQ and some others and I still can't figure this out. I created this little c# app. and I have a PictureBox in my Form. I load this image from the filesystem into the PictureBox and then I draw random little lines on the image. Then when I minimize and reopen the application the little lines are gone. Is there a way to save my lines in memory and...
6
2146
by: Patrick Dugan | last post by:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image. The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't matter what icons are loaded. The first always shows up and any icons after that give me the error. Here is the offending code: The "DestinationPath" variable is the full path and filename of the icon
0
1912
by: Deepak C.G via .NET 247 | last post by:
I want to dispose the image object in my child form, unless I won't dispose this object i can't delete the image file in my folder. I get this error in MDIparent form "An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll" "Additional information: Invalid parameter used." Here is my code:-
4
9246
by: Charles | last post by:
Hello Everyone, I have been gettting great feedback from microsoft.public.vc.language group but after doing more searching I think my post should be directed to this group. I am trying to make a simple gif animation using VC++ and 13 different gif files and a timer. I am new to VC++ but played around with C++ for a few years. I am using Microsoft Visual Studio 2005 (VC++).
3
1339
by: martins | last post by:
Hi, Is there a way in VB.NET to get a JPEG Image Information ? like dimensions (Width x Height)...etc.. Thanks in advance
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9483
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10346
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
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
10096
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,...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7504
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
5386
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
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.