473,396 Members | 1,998 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,396 software developers and data experts.

Click a button on the form via code?

I want to call this function via code:
private void btnExit_Click(object sender, System.EventArgs e)
{
Close();
}
How do I do this?

Thanks!

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
http://www.vbmark.com
Get freeware, learn things, make money.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Nov 17 '05 #1
4 1904
From the form:

this.Invoke( new EventHandler(btnExit_Click), new object[]{this,
EventArgs.Empty});

Brendan

"vbMark" wrote:
I want to call this function via code:
private void btnExit_Click(object sender, System.EventArgs e)
{
Close();
}
How do I do this?

Thanks!

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
http://www.vbmark.com
Get freeware, learn things, make money.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Nov 17 '05 #2
Hi,

btnExit_Click ( null, null )

cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"vbMark" <no@email.com> wrote in message
news:Xn********************@199.45.49.11...
I want to call this function via code:
private void btnExit_Click(object sender, System.EventArgs e)
{
Close();
}
How do I do this?

Thanks!

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
http://www.vbmark.com
Get freeware, learn things, make money.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Nov 17 '05 #3
I forgot to mention, the code in my previous reply is for if you are making
that call from another thread and want the call to occur within the main
thread.

Otherwise, if both are the same thread, you can simply call the function
from within the class with:

btnExit_Click(this, EventArgs.Empty);

Brendan

"vbMark" wrote:
I want to call this function via code:
private void btnExit_Click(object sender, System.EventArgs e)
{
Close();
}
How do I do this?

Thanks!

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
http://www.vbmark.com
Get freeware, learn things, make money.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Nov 17 '05 #4
Thank you. Your code works fine but did not solve my bigger problem
which I posted in another thread.
"=?Utf-8?B?QnJlbmRhbiBHcmFudA==?=" <gr****@NOSPAMdahat.com> wrote in
news:91**********************************@microsof t.com:
I forgot to mention, the code in my previous reply is for if you are
making that call from another thread and want the call to occur within
the main thread.

Otherwise, if both are the same thread, you can simply call the
function from within the class with:

btnExit_Click(this, EventArgs.Empty);

Brendan

"vbMark" wrote:
I want to call this function via code:
private void btnExit_Click(object sender, System.EventArgs e)
{
Close();
}
How do I do this?

Thanks!

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
http://www.vbmark.com
Get freeware, learn things, make money.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
http://www.vbmark.com
Get freeware, learn things, make money.
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Nov 17 '05 #5

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

Similar topics

3
by: Cary Linkfield | last post by:
I have a standard form I use. It inherits from Windows.Forms.Form. I usually add a Cancel button the form in the designer. I want to raise the Cancel button's Click event when the user presses...
6
by: Sally | last post by:
I need to be able to click in a subform and run code but at the same time I need to be able to scroll the records without running the code. I tried coding the Enter event of the subform control but...
3
by: Scott Schade | last post by:
I have a form onto which I add a control during execution. The control is a control that I wrote. The control has a number of controls on it. I would like to click on a button on the control and...
5
by: Steve | last post by:
Hi, Is it possible to make hitting the enter key in an ASP textbox run the code behind an ASP button on a form? I have a search page which users tend to type in the query then just hit enter...
4
by: Mark Lingen | last post by:
I've found a problem with postback event handling and webcontrol buttons. Try out the following code in an ASP.Net project and you will see. Create a web project in VB.Net and drop this code...
3
by: Neil Wallace | last post by:
Hi, This is an odd one. I've been struggling to get "double click" to work well for my controls. The same event handler works perfectly for buttons, but not for labels. Can anyone tell me...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
2
by: Joergen Bech | last post by:
Hope someone has a solution or some suggestions for this. This cannot be right?!? Problem: I have multiple non-modal forms open at the same time. One or more of these forms have a...
3
by: bettyboo | last post by:
Hi I'm new to the forum and also a VERY new user of Access to develop databases. I'm building a DB for a driving instructor acquaintance, and he wants a button on the pupil data entry form which...
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: 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
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
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,...
0
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...
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...
0
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,...

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.