473,396 Members | 2,013 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.

Force button event?

Hello,

I have a form with several buttons.

If a user clicks on one I want it to call the Click() event of another
button.

In VB6 this is very easy but they've changed it in .NET.

Can't we just do: call mybutton_click() anymore?

Thanks,
Adam Honek
Nov 21 '05 #1
14 7573
Adam Honek wrote:
Hello,

I have a form with several buttons.

If a user clicks on one I want it to call the Click() event of another
button.

In VB6 this is very easy but they've changed it in .NET.

Can't we just do: call mybutton_click() anymore?

Thanks,
Adam Honek


have you tried using "Handles Button2.Click"

--

Daniel
MCSE, MCP+I, MCP in Windows 2000/NT

--------------------------------------
remove the 2nd madrid from my mail address to contact me.
Nov 21 '05 #2
Yes but it won't work.

Right now I have something like this:

If e.KeyCode = Keys.Enter Then

handles btnX.Click()

End If

Adam

"Daniel" <da****@madridmadridsoleado.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Adam Honek wrote:
Hello,

I have a form with several buttons.

If a user clicks on one I want it to call the Click() event of another
button.

In VB6 this is very easy but they've changed it in .NET.

Can't we just do: call mybutton_click() anymore?

Thanks,
Adam Honek


have you tried using "Handles Button2.Click"

--

Daniel
MCSE, MCP+I, MCP in Windows 2000/NT

--------------------------------------
remove the 2nd madrid from my mail address to contact me.

Nov 21 '05 #3
Adam,

myButton.PerformClick might be what you need.

Kerry Moorman
"Adam Honek" wrote:
Hello,

I have a form with several buttons.

If a user clicks on one I want it to call the Click() event of another
button.

In VB6 this is very easy but they've changed it in .NET.

Can't we just do: call mybutton_click() anymore?

Thanks,
Adam Honek

Nov 21 '05 #4
Adam Honek wrote:
Can't we just do: call mybutton_click() anymore?


You can (though you'll have to pass the appropriate parameters), but a
better way is to call the button's PerformClick method.

--

(O)enone
Nov 21 '05 #5
The way I would do this is write a freestanding subroutine to do what I
wanted, then call it from both button click subroutines at the appropriate
time.

Bobbo
Nov 21 '05 #6
Bingo, exactly what I need.

Geez they've sure changed things round.

Thanks,
Adam

"Kerry Moorman" <Ke**********@discussions.microsoft.com> wrote in message
news:E6**********************************@microsof t.com...
Adam,

myButton.PerformClick might be what you need.

Kerry Moorman
"Adam Honek" wrote:
Hello,

I have a form with several buttons.

If a user clicks on one I want it to call the Click() event of another
button.

In VB6 this is very easy but they've changed it in .NET.

Can't we just do: call mybutton_click() anymore?

Thanks,
Adam Honek

Nov 21 '05 #7
"Adam Honek" <Ad*******@Webmaster2001.freeserve.co.uk> schrieb:
I have a form with several buttons.

If a user clicks on one I want it to call the Click() event of another
button.

In VB6 this is very easy but they've changed it in .NET.

Can't we just do: call mybutton_click() anymore?


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://classicvb.org/petition/>

Nov 21 '05 #8
Adam,

This one does it forever.

button_Click(nohing,nothing)

I hope this helps,

Cor
Nov 21 '05 #9
Cor,

"Cor Ligthert" <no************@planet.nl> schrieb:
This one does it forever.

button_Click(nohing,nothing)


Mhm... I would not use this one, because the event contract will be broken
(no sender and event arguments are sent).

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

Nov 21 '05 #10
Herfried,
Mhm... I would not use this one, because the event contract will be
broken (no sender and event arguments are sent).


Ignoring the nohing (typo). I thought today, let me do it very clean. I
used the performclick. Because of your message in this thread, do I now know
why that did not go.

Maybe you understand now as well why I made this message, it was to help the
OP not to have the same problem as me today.

:-)

By the way when what you tell is a problem than a simple
\\\
If sender is Nothing then 'do something
or in VB2005
If Not sender IsNot Nothing then 'do something
///

Does overcome that problem

:-)

Cor
Nov 21 '05 #11
Cor,

"Cor Ligthert" <no************@planet.nl> schrieb:
Mhm... I would not use this one, because the event contract will be
broken (no sender and event arguments are sent).
Ignoring the nohing (typo). I thought today, let me do it very clean. I
used the performclick. Because of your message in this thread, do I now
know why that did not go.


'PerformClick' actually works under certain circumstances.
Maybe you understand now as well why I made this message, it was to help
the OP not to have the same problem as me today.
Sorry, I cannot follow you...
By the way when what you tell is a problem than a simple
\\\
If sender is Nothing then 'do something
or in VB2005
If Not sender IsNot Nothing then 'do something
///


I prefer 'If Not sender Is Nothing Then...' or 'If sender IsNot Nothing
Then...' ;-). However, I'd try to avoid this situation.

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

Nov 21 '05 #12
Herfried,
Maybe you understand now as well why I made this message, it was to help
the OP not to have the same problem as me today.

I had this problem today because as what you had described in this thread.

I tried to help the OP by giving the (nothing nothing) code, so that (let us
say), have the same problems, knows how to fix that.

By the way. The performclick is AFAIK only creating a
callEventFunction(nothing, nothing).

Cor

Nov 21 '05 #13
sht
so that (let us say), have the same problems, knows how to fix that.


so that (let us say) when he has the same problems, knows how to fix that

Cor
Nov 21 '05 #14
Cor,

"Cor Ligthert" <no************@planet.nl> schrieb:
By the way. The performclick is AFAIK only creating a
callEventFunction(nothing, nothing).


No, it isn't. It's creating a '(<reference to sender>, EventArgs.Empty)'!

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #15

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

Similar topics

1
by: Marco Maroni | last post by:
I have a form with two or more INPUT TYPE (image, submit, button) objects, how can I force the ENTER event to act on a specific object and not to the first ? -- Marco Maroni
3
by: Arulraja | last post by:
Hello, I have created 2 custom server controls, The parent custom control contains multiple child custom controls. The Child control has a button on it. If I Click the button control, it...
1
by: JezB | last post by:
I have a button which implicitly posts-back before firing the event that I have attached to that button. Within that event code I modify the controls collection on the page so I want to force...
8
by: Amirallia | last post by:
Hello I want to force the Page.IsPostBack to false when I click an "asp:button" Is it possible ? -- Ceci est une signature automatique de MesNews. Site : http://www.mesnews.net
8
by: Keith H | last post by:
I'm looking for a way to force the user to re-authenticate with their Windows username/password/domain after clicking the submit button on an ASP.NET page. This is for an internal application. ...
4
by: Jordi Rico | last post by:
Hi, I'd like to know if there's any way to force a DateTimePicker to dropdown, something like PerformClick() in a button... I'd like to force this dropdown from the click event in other button...
1
by: BudhramM | last post by:
Hi, I have a webpage that has 2 ASP.Net buttons as well as some other controls. The controls are split up into two, there is a set of Combo boxes and then there is a single text input box. The...
51
by: Paul Gorodyansky | last post by:
Hi, Ran into the following problem while trying to have a code to attach a Virtual Keyboard to any user's form: User clicks a button and my JavaScript changes outerHTML of say <textarea -...
4
by: anudu | last post by:
hi, im dveloping a web system using vs 2008. in my page i have a ajax page method wich is called by javascript function . in onsuceeded method i want to force the save button on my page to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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,...
0
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...

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.