Bonjour,

Dans le cadre d'un projet Winform, je souhaite décrémenté un score de 100 avec le nombre de clics sur deux boutons différents.

Si l'on clic sur le bouton 1 on enlève 20 points au score.
Si l'on clic sur le bouton 2 on enlève 5 points au score.

J'appelle une Form lorsque le score est inférieur ou égal à 0.

Le problème que j'ai c'est que je n'arrive pas à lier le rafraichissement du score entre le bouton 1 et le bouton 2.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
namespace Entrainement1WinForm
{
    public partial class frm_Form2 : Form
    {
        int randomNumber;       
        List<string> indexImageReponse = new List<string>();
        int buttonClickCount1 = 0;
        int buttonClickCount2 = 0;
        int scorefn = 0;
        public int scoref = 100;
        int score1 = 0;
        int score2 = 0;
        bool x ;
 
        public frm_Form2()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
 
        }
        public void frm_NouvellePartie_Load(object sender, EventArgs e)
        {
 
            scorefn = scoref - (score2 + score1);
            txt_textBox1.Text = "Votre score est de: " + scorefn.ToString();   
 
 
        }
 
         private void Remove_Click(object sender, EventArgs e)
        {
           buttonClickCount2 = buttonClickCount2 + 1;
           btn_Verify.Text = "Vous avez poser (" + buttonClickCount2.ToString() + ") questions!";
 
               score2 = ((buttonClickCount2 * 5));               
               txt_textBox1.Text = (scorefn - score2).ToString();
 
                   if (txt_textBox1.Text == 0.ToString())
                        {
                           MessageBox.Show("GAME OVER");
                           //score = 100 - (((buttonClickCount1) * 20) + (((buttonClickCount2) * 5)));
                           frm_MenuDuJeu fm = new frm_MenuDuJeu();
                           fm.Owner = this;
                           fm.ShowDialog();                  
                        }                                                                           
             }
         private void button1_Click(object sender, EventArgs e)
        {
          x = true;
 
          buttonClickCount1 = buttonClickCount1 + 1;           
          btn_proposition.Text = "Proposez une réponse!" + Environment.NewLine + "nbr proposition("+buttonClickCount1.ToString()+")";
 
            score1 = ((buttonClickCount1 * 20));
            txt_textBox1.Text = (scorefn - score1).ToString();
 
                MessageBox.Show("Cliquez sur ''OK'' et sélectionnez une image");
 
                  if (txt_textBox1.Text == 0.ToString())
                  {
                      MessageBox.Show("GAME OVER");
                      //score = 100 - (((buttonClickCount1) * 20) + (((buttonClickCount2) * 5)));
                      frm_MenuDuJeu fm = new frm_MenuDuJeu();
                      fm.Owner = this;
                      fm.ShowDialog();                        
                  }                                
           }         
}
Merci d'avance