i am making a program need 128 button
when u click on button color of button change to red
when you click it a gain it back to normal color
is there a way to code one button and the other take the same function
thank at all
Fire_Michel 0 Newbie Poster
Recommended Answers
Jump to PostButton[] btnsAry = (Button[])FindControlsOfType(/*this*/ form1, typeof(Button)); foreach (Button btn in btnsAry) btn.BackColor = Color.Red;
Or, you could use a list (List<>):
List<Control> btnList = ListControlsOfType(/*this*/ form1, typeof(Button)); foreach (Button btn in btnList) btn.BackColor = Color.Red;
Jump to PostThink about common event handler for buttons,
... private void Form1_Load(object sender, EventArgs e) { button1.Click += new EventHandler(commonHandler); button2.Click += new EventHandler(commonHandler); button3.Click += new EventHandler(commonHandler); button4.Click += new EventHandler(commonHandler); } void commonHandler(object sender, EventArgs e) { Button btn = sender as Button; if (btn.BackColor == …
All 7 Replies
DdoubleD 315 Posting Shark
Fire_Michel 0 Newbie Poster
DdoubleD 315 Posting Shark
kvprajapati 1,826 Posting Genius Team Colleague
DdoubleD 315 Posting Shark
Fire_Michel 0 Newbie Poster
Fire_Michel 0 Newbie Poster
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.