473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Call event

Hi.
How can I call some event in my code.
Example:
I have declared

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btntest.Click

'Code

End Sub

and in other place in code I want call event Button1_click.

How can I do IT?

Thanks for answers.


Nov 21 '05 #1
4 3151
You can just call the method. It is just a regular method after all.

Since you will have to supply the arguments (which often time aren't even
used), many people place the code in the handler into a separate method, and
have the handler just call this method. This other method can then be called
from elsewhere without having to worry about suplly the sender and e
arguments.

"John Wels" <dv*@post.sk> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Hi.
How can I call some event in my code.
Example:
I have declared

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btntest.Click

'Code

End Sub

and in other place in code I want call event Button1_click.

How can I do IT?

Thanks for answers.

Nov 21 '05 #2
John Wels,

You could do something like this:

Button1_Click(Button1, System.EventArgs.Empty)
or make a seperate procedure in your button1_Click.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
OtherSubDoSomething

end sub

private sub OtherSubDoSomething

'code

end sub
"John Wels" <dv*@post.sk> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
Hi.
How can I call some event in my code.
Example:
I have declared

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btntest.Click

'Code

End Sub

and in other place in code I want call event Button1_click.

How can I do IT?

Thanks for answers.

Nov 21 '05 #3
John,

"John Wels" <dv*@post.sk> schrieb:
How can I call some event in my code.
[...]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As [...]
and in other place in code I want call event Button1_click.


If the button is visible and enabled, you can call its 'PerformClick'
method. Alterantively you can take the code from the event handler and put
it into a separate procedure. This procedure can be called from within the
event handler and other procedures. If you really want to call the button's
'Click' event handler for some reason, you can pass 'EventArgs.Empty' in the
'e' parameter.

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

Nov 21 '05 #4
Hi,

Trying to call Form1.Button1_Click event from Form2.Button2_click.

Thanks.

From http://www.developmentnow.com/g/38_2...Call-event.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Feb 14 '07 #5

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

Similar topics

3
by: JoeK | last post by:
Hey all, I am automating a web page from Visual Foxpro. I can control all the textboxes, radio buttons, and command buttons using syntax such as: ...
3
by: David N | last post by:
Hi All, I just wonder if in C#, I can develop a user defined control that can call its parent function which is not yet developed. For example, how do I make my user control call a...
2
by: rawCoder | last post by:
Hi I am having this InvalidOperationException with message Cannot call Invoke or InvokeAsync on a control until the window handle has been created This is raised when i try to invoke a method...
13
by: jac | last post by:
Hae, I have a windows form with a ComboBox an other things. On that combobox I have an eventhandler on de selectedindexchanged. But somewhere in my code want to do excecute the same code that...
4
by: John | last post by:
Hi all, This really is quite an urgent matter. I have a page with multiple, dynamically-loaded user controls and when a user clicks on a button, the whole form is submitted. Now at this stage...
22
by: Ricky W. Hunt | last post by:
First, the subject probably doesn't use the correct terms but I'm not sure what it's called in VB. I'm writing a media player app. The subroutine that handles the "open file" button contains an...
7
by: Bonzo | last post by:
>From within a function, I want to pass a/some parameters to another function, AND all arguments, passed into this function. e.g. function firstFunction(){ //this function may have been...
4
by: Paul | last post by:
Hi, I've been struggling with this today, I'm developing a DotNet2.0 website in C# that needs to call a long running data query. Obviously this is a good candidate for an Asynchronous call, so...
3
by: Ignacio Machin | last post by:
How can I call an event from another event: I want to call : DropDownList_SelectedIndexChanged in: Page_Load
8
by: hoofbeats95 | last post by:
I don't think this should be this complicated, but I can't figure it out. I've worked with C# for several years now, but in a web environment, not with windows form. I have a form with a query...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...

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.