I have a form of c sharp, In winch I have Five Button.I want hit all buttons one by one dynamically.
Please send me complete Code of c sharp.

Recommended Answers

All 5 Replies

Member Avatar for Mouche

To programmatically press a button in C#, use the PerformClick() method on each button.

b1.PerformClick()
b2.PerformClick()
b3.PerformClick()
b4.PerformClick()
b5.PerformClick()

How I perform with iteration
As a Loop

How does this look.

var buttons = new[] { button1, button2, button3, button4, button5 };
Array.ForEach(buttons, b => b.PerformClick());

What you you select all (one by one, but all eventually)? Isnt this a bid odd?

Or did you mean something else?

thanks nick.crane ,You solved the problem .


and Thanks for Lamouche and Mitja Bonca

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.