Bonjour,

Voilà j'ai une fenêtre qui contient 2 listes et un bouton ajouter, lorsqu'on clique sur le bouton, une autre fenêtre s'ouvre où il y a 1 textbox, 1 checklistbox et 1 bouton valider, lorsque j'appuie sur valider je dois me retrouver sur la 1ère fenêtre ensuite la valeur qui était sur le textbox doit être ajouté sur une des listes suivant ce qui a été coché ds la checklistbox.

mon pb, c'est que j'essaie de le faire à partir du bouton valider et que je ne sais pas comment trouver la liste pour le mettre.

voici le code où il y a mes listes :
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
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace OniolContrat
{
    public partial class frmLists : Form
    {
        public frmLists()
        {
            InitializeComponent();
            this.Visible = true;
        }
 
        private void btnAddList_Click(object sender, EventArgs e)
        {
            frmAddList frmAddList = new frmAddList();
        }
 
        private void btnRemoveList_Click(object sender, EventArgs e)
        {
            //TODO:remove the selected occurent
        }
    }
}
et là celui où il y a ma textbox :
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
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace OniolContrat
{
    public partial class frmAddList : Form
    {
        public frmAddList()
        {
            InitializeComponent();
            this.Visible = true;
            //select by default OS
            chkListAdd.SetItemChecked(0, true);
        }
 
        private void btnValueAddList_Click(object sender, EventArgs e)
        {
            if (txtAddList != null)
            {
                if ((chkListAdd.GetItemChecked(0) == true) && (chkListAdd.GetItemChecked(1) == false))
                {
                    //TODO:add to the list OS
                    this.Close();
                }
                else if ((chkListAdd.GetItemChecked(0) == false) && (chkListAdd.GetItemChecked(1) == true))
                {
                    //TODO:add to the list Type Blé
                    this.Close();
                }
                else
                    MessageBox.Show("Vous devez cliquer soit OS soit Type Blé");
            }
            else
                MessageBox.Show("Vous devez saisir ou Annuler");
 
        }   
 
    }
}
sinon j'ai essayé aussi en faisant le contraire en fait voici les codes :
liste :
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
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace OniolContrat
{
    public partial class frmLists : Form
    {
        public frmLists()
        {
            InitializeComponent();
            this.Visible = true;
        }
 
        private void btnAddList_Click(object sender, EventArgs e)
        {
            frmAddList frmAddList = new frmAddList();
            frmAddList.Show();
            if (frmAddList.addInTheGoodList == "OS")
            {
                this.lstOS.Items.Add(frmAddList.addInTheList);
            }
            else if (frmAddList.addInTheGoodList == "Type Blé")
            {
                this.lstTypeBle.Items.Add(frmAddList.addInTheList);
            }   
 
        }
 
        private void btnRemoveList_Click(object sender, EventArgs e)
        {
            //TODO:remove the selected occurent
        }
    }
}
textbox :
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
72
73
74
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace OniolContrat
{
    public partial class frmAddList : Form
    {
        public frmAddList()
        {
            InitializeComponent();
            this.Visible = true;
            //select by default OS
            chkListAdd.SetItemChecked(0, true);
        }
 
        private void btnValueAddList_Click(object sender, EventArgs e)
        {
            if (txtAddList != null)
            {
                if (((chkListAdd.GetItemChecked(0) == false) && (chkListAdd.GetItemChecked(1) == false))
                    || ((chkListAdd.GetItemChecked(0) == true) && (chkListAdd.GetItemChecked(1) == true)))
                    MessageBox.Show("Vous devez cliquer soit OS soit Type Blé");
            }
            else
                MessageBox.Show("Vous devez saisir ou Annuler");
 
        }
 
        public string addInTheGoodList
        {
            set
            {
                if ((chkListAdd.GetItemChecked(0) == true) && (chkListAdd.GetItemChecked(1) == false))
                {
                    this.chkListAdd.Text = value;
                }
                else if ((chkListAdd.GetItemChecked(0) == false) && (chkListAdd.GetItemChecked(1) == true))
                {
                    this.chkListAdd.Text = value;
                }
            }
 
            get
            {
                if ((chkListAdd.GetItemChecked(0) == true) && (chkListAdd.GetItemChecked(1) == false))
                {
                    return (this.chkListAdd.Text);
                }
                else if ((chkListAdd.GetItemChecked(0) == false) && (chkListAdd.GetItemChecked(1) == true))
                {
                    return(this.chkListAdd.Text);
                }
            }
        }
 
        public string addInTheList
        {
            set
            {
                this.txtAddList.Text = value;
            }
            get
            {
                return (this.txtAddList.Text);
            }
        }
    }
}
mais là le pb, c'est qu'il n'aime pas trop que dans get de addInTheGoodList k'il y ait 2 fois return écrit.

si qq'1 peut m'aider, merci.