private void form(object sender, EventArgs e) { Button btForm = (Button)sender; AfficheFormation formation = (AfficheFormation)btForm.Parent; if (company.Money > formation.Price) { company.Money -= formation.Price; employeeSelected.Experience += formation.Xp; } }
public void DrawListFormation() { int j = 0; //Draw the list of the formations for (int i = 0; i < formationName.Count; i++) { AfficheFormation afficheFormation = new AfficheFormation(formationName[i], i); afficheFormation.TopLevel = false; afficheFormation.Location = new Point(0, j * 100); j++; afficheFormation.Show(); Button btnForm = afficheFormation.getBtForm(); btnForm.Click += new EventHandler(form); this.pnlFormations.Controls.Add(afficheFormation); } pnlFormations.Size = new Size(300, 300); //It is hidding but it will be shown if the player click on "Form" pnlFormations.Hide(); }