473,799 Members | 3,229 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is there an event for image change for a PictureBox Control? please help.

Hi! Can u please tech me a way to know if the image in the picturebox has
changed? what event should i catch the chage?
Jul 21 '05
15 1824
Hi,
Here is a Picture box control with two extra events , before image changed
and after image changed...

Imports System
Imports System.Windows. Forms
Imports System.Drawing. Drawing2D
Imports System.Drawing
<ToolboxBitmap( GetType(Picture Box))> _
Public Class adxPictureContr ol
Inherits PictureBox
Private _image As System.Drawing. Image
Event ImageBeforeChan ged(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)
Event ImageAfterChang ed(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)

Public Shadows Property Image() As Image
Get
Return _image
End Get
Set(ByVal Value As Image)

If Not Value Is _image Then
If Me.DesignMode Then
MyBase.Image = Value
_image = Value
Else
Dim ea As New EventArgsImageC hanged
If Not _image Is Nothing Then
RaiseEvent ImageBeforeChan ged(Me, ea)
If ea.Cancel = True Then
Exit Property
End If
End If
MyBase.Image = Value
_image = Value
RaiseEvent ImageAfterChang ed(Me, ea)
End If
End If
End Set
End Property

End Class
Public Class EventArgsImageC hanged
Inherits EventArgs
Private _cancel As Boolean = False
Public Property Cancel() As Boolean
Get
Return _cancel
End Get
Set(ByVal Value As Boolean)
_cancel = Value
End Set
End Property
End Class
"Cor Ligthert" wrote:
me 2 ;-)

Has to do with politness, I am sorry that you did not understand it.

When the OP ask something what is for you strange because the answer is
obvious, than you can give an answer, however you can as well do what I did
and ask what he means with his question, although you know almost for sure
your answer.

When than somebody else give in a (in my opinion kind of rude way) that
answer I am not happy.
In that way the OP will probably never ask a question here again.

I can than write nothing or ask to do it not again the next time.

Clear?

Cor

Jul 21 '05 #11
hi, try this one:

Imports System
Imports System.Windows. Forms
Imports System.Drawing. Drawing2D
Imports System.Drawing
<ToolboxBitmap( GetType(Picture Box))> _
Public Class adxPictureContr ol
Inherits PictureBox
Private _image As System.Drawing. Image
Event ImageBeforeChan ged(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)
Event ImageAfterChang ed(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)

Public Shadows Property Image() As Image
Get
Return _image
End Get
Set(ByVal Value As Image)

If Not Value Is _image Then
If Me.DesignMode Then
MyBase.Image = Value
_image = Value
Else
Dim ea As New EventArgsImageC hanged
If Not _image Is Nothing Then
RaiseEvent ImageBeforeChan ged(Me, ea)
If ea.Cancel = True Then
Exit Property
End If
End If
MyBase.Image = Value
_image = Value
RaiseEvent ImageAfterChang ed(Me, ea)
End If
End If
End Set
End Property

End Class
Public Class EventArgsImageC hanged
Inherits EventArgs
Private _cancel As Boolean = False
Public Property Cancel() As Boolean
Get
Return _cancel
End Get
Set(ByVal Value As Boolean)
_cancel = Value
End Set
End Property
End Class
"Cor Ligthert" wrote:
me 2 ;-)

Has to do with politness, I am sorry that you did not understand it.

When the OP ask something what is for you strange because the answer is
obvious, than you can give an answer, however you can as well do what I did
and ask what he means with his question, although you know almost for sure
your answer.

When than somebody else give in a (in my opinion kind of rude way) that
answer I am not happy.
In that way the OP will probably never ask a question here again.

I can than write nothing or ask to do it not again the next time.

Clear?

Cor

Jul 21 '05 #12
Here is a control you can use:
Imports System
Imports System.Windows. Forms
Imports System.Drawing. Drawing2D
Imports System.Drawing
<ToolboxBitmap( GetType(Picture Box))> _
Public Class adxPictureContr ol
Inherits PictureBox
Private _image As System.Drawing. Image
Event ImageBeforeChan ged(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)
Event ImageAfterChang ed(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)
'Avi D. New York, NY 2004
Public Shadows Property Image() As Image
Get
Return _image
End Get
Set(ByVal Value As Image)

If Not Value Is _image Then
If Me.DesignMode Then
MyBase.Image = Value
_image = Value
Else
Dim ea As New EventArgsImageC hanged
If Not _image Is Nothing Then
RaiseEvent ImageBeforeChan ged(Me, ea)
If ea.Cancel = True Then
Exit Property
End If
End If
MyBase.Image = Value
_image = Value
RaiseEvent ImageAfterChang ed(Me, ea)
End If
End If
End Set
End Property

End Class
Public Class EventArgsImageC hanged
Inherits EventArgs
Private _cancel As Boolean = False
Public Property Cancel() As Boolean
Get
Return _cancel
End Get
Set(ByVal Value As Boolean)
_cancel = Value
End Set
End Property
End Class

"Cor Ligthert" wrote:
me 2 ;-)

Has to do with politness, I am sorry that you did not understand it.

When the OP ask something what is for you strange because the answer is
obvious, than you can give an answer, however you can as well do what I did
and ask what he means with his question, although you know almost for sure
your answer.

When than somebody else give in a (in my opinion kind of rude way) that
answer I am not happy.
In that way the OP will probably never ask a question here again.

I can than write nothing or ask to do it not again the next time.

Clear?

Cor

Jul 21 '05 #13
AviD,
Event ImageBeforeChan ged(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)
Event ImageAfterChang ed(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)
Rather then ImageBeforeChan ged & ImageAfterChang ed you might consider naming
the events ImageChanging & ImageChanged which is the normal convention for
..NET.

http://msdn.microsoft.com/library/de...Guidelines.asp

http://msdn.microsoft.com/library/de...Guidelines.asp
Public Class EventArgsImageC hanged
Inherits EventArgs
Private _cancel As Boolean = False Rather then define a class with a Cancel Property you can simply use
System.Componen tModel.CancelEv entArgs or inherit from it.

http://msdn.microsoft.com/library/de...classtopic.asp
Public Class adxPictureContr ol
Inherits PictureBox
Public Event ImageChanging As System.Componen tModel.CancelEv entHandler
Public Event ImageChanged As System.Event Handler

...
End Class

Hope this helps
Jay

"AviD" <av*@newsgroup. nospam> wrote in message
news:A1******** *************** ***********@mic rosoft.com... hi, try this one:

Imports System
Imports System.Windows. Forms
Imports System.Drawing. Drawing2D
Imports System.Drawing
<ToolboxBitmap( GetType(Picture Box))> _
Public Class adxPictureContr ol
Inherits PictureBox
Private _image As System.Drawing. Image
Event ImageBeforeChan ged(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)
Event ImageAfterChang ed(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)

Public Shadows Property Image() As Image
Get
Return _image
End Get
Set(ByVal Value As Image)

If Not Value Is _image Then
If Me.DesignMode Then
MyBase.Image = Value
_image = Value
Else
Dim ea As New EventArgsImageC hanged
If Not _image Is Nothing Then
RaiseEvent ImageBeforeChan ged(Me, ea)
If ea.Cancel = True Then
Exit Property
End If
End If
MyBase.Image = Value
_image = Value
RaiseEvent ImageAfterChang ed(Me, ea)
End If
End If
End Set
End Property

End Class
Public Class EventArgsImageC hanged
Inherits EventArgs
Private _cancel As Boolean = False
Public Property Cancel() As Boolean
Get
Return _cancel
End Get
Set(ByVal Value As Boolean)
_cancel = Value
End Set
End Property
End Class
"Cor Ligthert" wrote:
> me 2 ;-)
>

Has to do with politness, I am sorry that you did not understand it.

When the OP ask something what is for you strange because the answer is
obvious, than you can give an answer, however you can as well do what I
did
and ask what he means with his question, although you know almost for
sure
your answer.

When than somebody else give in a (in my opinion kind of rude way) that
answer I am not happy.
In that way the OP will probably never ask a question here again.

I can than write nothing or ask to do it not again the next time.

Clear?

Cor

Jul 21 '05 #14
Hi Jay
Advice well taken!
AviD.
"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:ei******** ******@tk2msftn gp13.phx.gbl...
AviD,
Event ImageBeforeChan ged(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)
Event ImageAfterChang ed(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)


Rather then ImageBeforeChan ged & ImageAfterChang ed you might consider
naming the events ImageChanging & ImageChanged which is the normal
convention for .NET.

http://msdn.microsoft.com/library/de...Guidelines.asp

http://msdn.microsoft.com/library/de...Guidelines.asp
Public Class EventArgsImageC hanged
Inherits EventArgs
Private _cancel As Boolean = False

Rather then define a class with a Cancel Property you can simply use
System.Componen tModel.CancelEv entArgs or inherit from it.

http://msdn.microsoft.com/library/de...classtopic.asp
Public Class adxPictureContr ol
Inherits PictureBox


Public Event ImageChanging As System.Componen tModel.CancelEv entHandler
Public Event ImageChanged As System.Event Handler

...
End Class

Hope this helps
Jay

"AviD" <av*@newsgroup. nospam> wrote in message
news:A1******** *************** ***********@mic rosoft.com...
hi, try this one:

Imports System
Imports System.Windows. Forms
Imports System.Drawing. Drawing2D
Imports System.Drawing
<ToolboxBitmap( GetType(Picture Box))> _
Public Class adxPictureContr ol
Inherits PictureBox
Private _image As System.Drawing. Image
Event ImageBeforeChan ged(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)
Event ImageAfterChang ed(ByVal sender As Object, ByVal e As
EventArgsImageC hanged)

Public Shadows Property Image() As Image
Get
Return _image
End Get
Set(ByVal Value As Image)

If Not Value Is _image Then
If Me.DesignMode Then
MyBase.Image = Value
_image = Value
Else
Dim ea As New EventArgsImageC hanged
If Not _image Is Nothing Then
RaiseEvent ImageBeforeChan ged(Me, ea)
If ea.Cancel = True Then
Exit Property
End If
End If
MyBase.Image = Value
_image = Value
RaiseEvent ImageAfterChang ed(Me, ea)
End If
End If
End Set
End Property

End Class
Public Class EventArgsImageC hanged
Inherits EventArgs
Private _cancel As Boolean = False
Public Property Cancel() As Boolean
Get
Return _cancel
End Get
Set(ByVal Value As Boolean)
_cancel = Value
End Set
End Property
End Class
"Cor Ligthert" wrote:
> me 2 ;-)
>
Has to do with politness, I am sorry that you did not understand it.

When the OP ask something what is for you strange because the answer is
obvious, than you can give an answer, however you can as well do what I
did
and ask what he means with his question, although you know almost for
sure
your answer.

When than somebody else give in a (in my opinion kind of rude way) that
answer I am not happy.
In that way the OP will probably never ask a question here again.

I can than write nothing or ask to do it not again the next time.

Clear?

Cor


Jul 21 '05 #15
The only solution I can think of, is to Inherit from a PictureBox, and
override (or shadow, for that matter) the Image property. I needed to do
that to make a PictureBox that supported "DBNull" values, and it worked
Ok... Then you can call MyBase.Image to set or get the PictureBox's real
values.
Hope this helps.
VBen.

"Jose Michael Meo R. Barrido" <mi**@rdmsinc.n et> escribió en el mensaje
news:uq******** ******@TK2MSFTN GP09.phx.gbl...
Hi! Can u please tech me a way to know if the image in the picturebox has
changed? what event should i catch the chage?

Jul 21 '05 #16

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

Similar topics

5
4904
by: BrianW | last post by:
I am working on a program that has multiple picturebox controls that a user is allowed to move around which are contained within a panel control for visual placement. In my mousedown event, I set the picturebox control's borderstyle to Fixed3D, but upon doing so, I am not able to track the picturebox control through mousemove events (if you move the mouse off of the control too quickly, the control no longer receives mouse events). If I...
21
8887
by: Jose Michael Meo R. Barrido | last post by:
Hi! Can u please tech me a way to know if the image in the picturebox has changed? what event should i catch the chage?
38
3033
by: johnb41 | last post by:
I have a Picturebox that has an image displayed inside. Through code, I was able to have the "whole image" display in it without distortion. (Like a "Fit All" in most any image viewer program) Now, when the Picturebox gets resized by the user, I want the image to recalculate and display as "Fit All" again. So I have code in my SizeChanged event of the picturebox. When the "size changed", it does it's calculation, and displays properly.
4
5393
by: Rich | last post by:
Hello, I create multiple pictureboxe controls on a form in a For Loop and display thumbnail pictures. I need to add a Click event to these pictureboxes. Here is the routine that creates the pictureboxes: ---------------------------------------------------------------------------- Dim MynewPos As New Point(50, 40) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
1
2495
by: euroluxantiques | last post by:
Hi All, Using VB.Net with SQL Server. I have a form that I create a number of Picture Boxes on dynamically, based on a stored procedure that retrieves a listing of images available for a particular product and populates the picture boxes using the paths found by the stored procedure. Anyway, that part works great. I have the Picture Boxes set a 231 px wide by 231 px high, and I want to resize these in a separate box when a user hovers...
0
10482
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
10251
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
10225
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
10027
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
7564
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
5463
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
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
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
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.