Hey there.

How do i execute the code in button1 when i click on button2?

I have no idea and will save me alot of coding

thank you =)

Recommended Answers

All 5 Replies

Hey there.

How do i execute the code in button1 when i click on button2?

I have no idea and will save me alot of coding

thank you =)

No Worries, i found it.

button2.PerformClick();

Chow

So if you have a button, say "Print document" you have a second button and you want it to perform the same action?
You could put a call to the same method in both buttons, if that is what you really want to do. Or else I misunderstood your question. In that case more explanation is appreciated.

Guess our responses just crossed :)

So if you have a button, say "Print document" you have a second button and you want it to perform the same action?
You could put a call to the same method in both buttons, if that is what you really want to do. Or else I misunderstood your question. In that case more explanation is appreciated.

=) Yes thats exactly what i wanted to do. =) i just found out how to accomplish it, because i was trying to update my datagridwiew, and i can do it 100% with a button, but as soon as i try to do it with a menu strip, it doesnt want to.

So i thought ill just invoke the update button again. i found out you can do it with

button2.PerformClick();

Thank you =)

Guess our responses just crossed :)

haha, well have a good day =)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.