can anybody tell me how can i create array of buttons so that i can give same code to every button
er.sajal
0
Newbie Poster
Recommended Answers
Jump to PostButton[] btnArr = new Button[COUNT]; //count is the amount of buttons this array can hold. //Add/Change a button: btnArr[indx] = IAmButton; //indx is the position, IAmButton is the button you are adding. //Get a button: IAmButton = btnArr[indx]; //Get a specific button. Not so sure about this …
Jump to Post"Give same Code ??"
Do you mean giving them all the same event handler ? then let the event handler determine the button that was used ?
Jump to PostOkay, then if I can assume that the buttons already exist on the form, then simply have all the buttons point to the same event handler, and examine the object sender to determine which button was pressed.
Button btn = sender as Button;
Now btn is the button thas …
All 9 Replies
scru
909
Posting Virtuoso
Featured Poster
JerryShaw
46
Posting Pro in Training
er.sajal
0
Newbie Poster
JerryShaw
46
Posting Pro in Training

Moirae
ddanbe
2,724
Professional Procrastinator
Featured Poster

Moirae
sknake
1,622
Senior Poster
Featured Poster
S.Santosh
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.