Simulating menu clicks

  • Thread starter Thread starter John Dann
  • Start date Start date
J

John Dann

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
 
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
 
* John Dann said:
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.
 
Cor,

* "Cor Ligthert said:
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,
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
 
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
 
* "Samuel L Matzen said:
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 ;-).
 
Back
Top