469,926 Members | 1,526 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

Simulating menu clicks

I've either completely forgotten how to do this or it's different in
VB.Net from VB6, but how do I call the routine for a menu click
programmatically? (ie I want to simulate and call mnuTest_click). I
don't know what arguments to supply in the call.

TIA
John Dann
Nov 20 '05 #1
8 1794
Hi John,

You only have to call the event method that does the mnuTest_Click and
because you have to give the arguments is the most simple for that

mnuTest_Click(Nothing,Nothing)

(There are more methods so probably you get 4 others as well, this is the
most simple one in my opinion)

Cor
I've either completely forgotten how to do this or it's different in
VB.Net from VB6, but how do I call the routine for a menu click
programmatically? (ie I want to simulate and call mnuTest_click). I
don't know what arguments to supply in the call.

TIA
John Dann

Nov 20 '05 #2
Cor,

* "Cor Ligthert" <no**********@planet.nl> scripsit:
You only have to call the event method that does the mnuTest_Click and
because you have to give the arguments is the most simple for that

mnuTest_Click(Nothing,Nothing)

(There are more methods so probably you get 4 others as well, this is the
most simple one in my opinion)


Mhm... What if I want to get the reference to the item in the 'sender'
parameter of the handler? Passing 'Nothing' to the handler is IMO not
the best idea.

Just my 2 Euro cents...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
* John Dann <ne**@prodata.co.uk> scripsit:
I've either completely forgotten how to do this or it's different in
VB.Net from VB6, but how do I call the routine for a menu click
programmatically? (ie I want to simulate and call mnuTest_click). I
don't know what arguments to supply in the call.


Call the 'MenuItem''s 'PerformClick' method.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Herfried,
You only have to call the event method that does the mnuTest_Click and
because you have to give the arguments is the most simple for that

mnuTest_Click(Nothing,Nothing)

(There are more methods so probably you get 4 others as well, this is the most simple one in my opinion)


Mhm... What if I want to get the reference to the item in the 'sender'
parameter of the handler? Passing 'Nothing' to the handler is IMO not
the best idea.


With the menu item for a newbie in VBNet? Before he can use the sender
object from the menu item he is already that far that he knows how to do it
with other objects, and the eventargument from the *click* event is not the
one that I have ever used.

However I did not say it was the best method, I said the most simple and
special in this case I think.

:-)

Cor
Nov 20 '05 #5
Herfried,

Then just send a reference to the control you want to use as the sender.

You can also create an instance of the event args and populate them if you
want to.

Then the event method won't be able to tell if the event was fired from
inside the control or created within your application.

-Sam Matzen
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:e3**************@tk2msftngp13.phx.gbl...
Cor,

* "Cor Ligthert" <no**********@planet.nl> scripsit:
You only have to call the event method that does the mnuTest_Click and
because you have to give the arguments is the most simple for that

mnuTest_Click(Nothing,Nothing)

(There are more methods so probably you get 4 others as well, this is the most simple one in my opinion)


Mhm... What if I want to get the reference to the item in the 'sender'
parameter of the handler? Passing 'Nothing' to the handler is IMO not
the best idea.

Just my 2 Euro cents...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #6
* "Samuel L Matzen" <sm*****@slm.com> scripsit:
Then just send a reference to the control you want to use as the sender.

You can also create an instance of the event args and populate them if you
want to.

Then the event method won't be able to tell if the event was fired from
inside the control or created within your application.


ACK, but then I would use 'PerformClick' instead ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #7
Herfried,

Selective answering?
* "Samuel L Matzen" <sm*****@slm.com> scripsit:
Then just send a reference to the control you want to use as the sender.

You can also create an instance of the event args and populate them if you want to.

Then the event method won't be able to tell if the event was fired from
inside the control or created within your application.


ACK, but then I would use 'PerformClick' instead ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #8
Cor,

* "Cor Ligthert" <no**********@planet.nl> scripsit:
Selective answering?


???

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Pedro Sebastiao | last post: by
3 posts views Thread by Anand Ganesh | last post: by
reply views Thread by Mojtaba Faridzad | last post: by
1 post views Thread by Ignacio X. Domínguez | last post: by
reply views Thread by Andrew Teece | last post: by
2 posts views Thread by Paul E Collins | last post: by
1 post views Thread by =?Utf-8?B?QW5kcmV3?= | last post: by
1 post views Thread by Mike | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.