TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tomas Westerlund
NA
38
32.5k
I have 2.75 million buttons - Do I need do create a new Button_click() for each button?
Aug 26 2011 5:31 AM
Hi,
I am creating a small game where you can buy animals, food etc.
I have a class for the animals as well as the food and you can buy food through the buttons (a "+" and a "-" button) and the same with the food.
However I have ~10 animals and the buttons to the same thing (based on the set property). Do I need to create a new Button_Click for each button?
Here is the code for one button for example:
private void penguinSub_Click(object sender, EventArgs e)
{
if (Penguin.Amount > 0)
{
Penguin.Amount -= 1;
money = money + (int)(Convert.ToDouble(Penguin.Cost * 0.9));
reloadLabels();
}
}
Also the Tiger_Button will do the exactly same thing but lower Tiger.Amount instead of Penguin.Amount (and so forth).
Reply
Answers (
4
)
Adjust Multiple Group Header With Multiple Details Section
Why fails to build this class?