473,549 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Invoking a PictureBox click ?

Hi all,

The Click event handler of a button control can be invoked using the
Button.PerformC lick method. But I have a Picturebox, whose click event
handler I want to invoke. RaiseEvent doesn't seem to apply in this case. I
could set up a Custom method and call that method instead, but it would
require some recoding, so I was wondering if the Event can be raised
directly. (I vaguely recall a way to do this, but it's evading me right
now!)

Private Sub PicBox_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles PicBox.Click
'My code here.
End Sub

How do I call this method, or raise the Click event for the PictureBox ?

Thanks in advance,

Regards,

Cerebrus.
Feb 15 '06 #1
3 7483
As long as the sender and e arguments are of no consequence to the piece of
magic contained in 'My code here., then you can simply call:

PicBox_Click(No thing, Nothing)

A cleaner way to deal with it though, is to seperate the desired operation
from the event handler:

Private Sub PicBoxClickHand ler()
'My code here.
End sub

The 'My code here. in PicBox_Click now becomes:

PicBoxClickHand ler()

which can also be called quite cleanly from anywhere that can access the
procedure.
"Cerebrus99 " <zo*****@sify.c om> wrote in message
news:Oz******** ******@TK2MSFTN GP12.phx.gbl...
Hi all,

The Click event handler of a button control can be invoked using the
Button.PerformC lick method. But I have a Picturebox, whose click event
handler I want to invoke. RaiseEvent doesn't seem to apply in this case. I
could set up a Custom method and call that method instead, but it would
require some recoding, so I was wondering if the Event can be raised
directly. (I vaguely recall a way to do this, but it's evading me right
now!)

Private Sub PicBox_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles PicBox.Click
'My code here.
End Sub

How do I call this method, or raise the Click event for the PictureBox ?

Thanks in advance,

Regards,

Cerebrus.

Feb 15 '06 #2
Hi Stephany,

Thanks for your prompt response.

I tried PicBox_Click and it works fine. I was missing out something obvious
and was trying to call PicBox.Click(no thing, nothing). Didn't realize that I
should change it to PicBox_Click ! Thanks a lot.

Regards,

Cerebrus.

"Stephany Young" <noone@localhos t> wrote in message
news:OZ******** *****@TK2MSFTNG P14.phx.gbl...
As long as the sender and e arguments are of no consequence to the piece of magic contained in 'My code here., then you can simply call:

PicBox_Click(No thing, Nothing)

A cleaner way to deal with it though, is to seperate the desired operation
from the event handler:

Private Sub PicBoxClickHand ler()
'My code here.
End sub

The 'My code here. in PicBox_Click now becomes:

PicBoxClickHand ler()

which can also be called quite cleanly from anywhere that can access the
procedure.
"Cerebrus99 " <zo*****@sify.c om> wrote in message
news:Oz******** ******@TK2MSFTN GP12.phx.gbl...
Hi all,

The Click event handler of a button control can be invoked using the
Button.PerformC lick method. But I have a Picturebox, whose click event
handler I want to invoke. RaiseEvent doesn't seem to apply in this case. I could set up a Custom method and call that method instead, but it would
require some recoding, so I was wondering if the Event can be raised
directly. (I vaguely recall a way to do this, but it's evading me right
now!)

Private Sub PicBox_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles PicBox.Click
'My code here.
End Sub

How do I call this method, or raise the Click event for the PictureBox ?

Thanks in advance,

Regards,

Cerebrus.


Feb 15 '06 #3
"Stephany Young" <noone@localhos t> schrieb:
As long as the sender and e arguments are of no consequence to the piece
of magic contained in 'My code here., then you can simply call:

PicBox_Click(No thing, Nothing)


Avoid doing that! Instead, call 'PicBox_Click(M e.PixBox, EventArgs.Empty )'
or, even better, use a separate procedure (as you already described).

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

Feb 15 '06 #4

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

Similar topics

0
3157
by: 6tc1 | last post by:
Hi all, I've got a UserControl that contains a few PictureBox objects. If I click on outside of the Picture in the UserControl, the scrolling with the mouse button works - however, no amount of clicking on the PictureBox objects will get that scrolling working. However, after I click on outside of the PictureBox object, then click as many...
9
14803
by: SStory | last post by:
I have a picturebox in my About form. would like to have a link to my company website. Wanted the links background to be transparent. It seems that no one knows how to do this. Have asked many times. VB help says that transparent is possible with a background image but not above a control. So how can I provide a link (URL) that is...
0
3867
by: akh | last post by:
I want to use de Drag and Drop ´s event to move a picture box from a form and within a Picture Box. But I have behaviour if the MyPBox As PictureBox as the Globale varible or not Thanks for your help, Here is the code.
2
10327
by: kalp suth via DotNetMonster.com | last post by:
I want to create arrows using lines on a picture in the picture box. On clicking the button "btnShowAll", the image is loaded and the lines drawn. "RGSShowAll()" calls "DrawObjs()" which does the actual drawing work. But after displaying all the arrows in a flick, the arrows disappers. I have debugged and came to know that the "Paint" event...
2
6121
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for loading images into the picturebox. If you double click the file you want to open in the open file dialog, it somehow interperets one of the clicks...
5
4542
by: toby | last post by:
Hi there, Is it possible to create an array of picturebox controls during run-time. I wish to create a new image/picturebox everytime a user clicks the button on a form, and they need to be objects so that the user can move/drag them around. The only examples I can find dont work as I am using VB Express (2005?)
6
25775
by: robusto33 | last post by:
Hi everyone, I'm really new to C#.net development, especially for win32 applications. I'm basically making a board game and was wondering if anyone could help me out with this predicament: I have a dynamically created array based on the size of the Board (13x13 or 19x19). I can make the array fine and position the pictureBoxes over the...
4
3802
by: munibe | last post by:
Hi, i have a problem about picturebox control. if you may help me, i will be so happy. i have a picturebox named pic_map, and i added a button named customer_button, my wish is to add a new small picturebox on the map_picture and the new added picturebox should have click event to get the location of it when it is clicked. i have written some...
4
3690
by: Jim McGivney | last post by:
In C# on Form1 I genetate an array of PictureBoxes and populate each with an image as seen in the code below. Later on I want to access a specific PictureBox to change its image, but I keep getting the error "The name 'PictureBox1' does not exist in the current context" The code I use to try to access the PictureBox is "PictureBox1.Image =...
0
7542
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...
0
7467
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...
0
7736
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. ...
0
7827
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...
0
6066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5385
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...
0
3514
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...
0
3494
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1961
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

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.