Premo un tasto con un evento: solita domanda, come?

C

Ciccio

Scusate se è la solita domanda ma neanche con San Google ho trovato un
esempio di codice semplice che mi facesse capire.
Il tasto Button1 con Button1_Click fa tante cose.
Da un'altra parte del programma vorrei facesse le stesse cose se
soddisfatta una certa if.
O faccio una funzione che poi chiamo da tutte e 2 le parti o scateno
l'evento Button1_Click.
Ecco: come premo il tasto via software?
Grazie.
 
C

Cor Ligthert [MVP]

Ciccio,

I see that my understanding from Italian becomes worse and worse, I am
probably not the only one, although that this newsgroup is visited by
persons from all over the world do we like to communicatie in English.

If I understand your question well, than is it often asked and answered in
this newsgroup. Answers are.

Create an independent sub where your click even and your program can point
to.

Use the buttony.performclick although that does not work if the button has
no focus (I don't like that one anymore).

Use the function that points to your buttonclick event something as
preferend by me
button1_click(nothing, nothing)
or as preferred by others
button1_click(me, nothing)
or as preferred by again others if done in an event which has as well
System.EventArgs
button1_click(me, e)
if it is not from that I thought they do something as this
dim Hefried as new system.eventsargs
button1_Click(me, Herfried).

However as I said I prefer (in most cases for this) the
button1_Click(Nothing, Nothing) to know if it is than from the program, than
the only thing I have to do is

if sender Is Nothing then
'I am not from the program
else
'else a button is clicked
end if

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top