Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
4
Reply
I have 2.75 million buttons - Do I need do create a new Button_click() for each button?
Tomas Westerlund
Aug 26 2011 5:31 AM
1.7k
Reply
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).
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
Adjust Multiple Group Header With Multiple Details Section
Why fails to build this class?