Bonjour,

j'appelle ma fenetre recherche client de la façon suivante :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
rechercheclient recherche = new recherchecleint();
recherche .showdialog;
Mais le tps de chargment est trop long voici le code de ma fenetre rechercheclient

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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace WindowsFormsApplication1
{
    public partial class RechercheClients : Form
    {
       public Form3 _form3;
 
 
        public RechercheClients(Form3 o )
        {
            InitializeComponent();
            _form3 = o;
 
        }
 
        private void labelAcheteur_Click(object sender, EventArgs e)
        {
 
        }
 
        static bool Odd(int value)
        {
            return (value & 1) == 1;
        }
 
        public void changercouleur()
        {
 
            for (
                int i = 0; i < this.listView1.Items.Count; i++)
            {
                if (Odd(i) == true)
                {
                    bool b = false;
                    string CodeCommenataire = this.listView1.Items[i].SubItems[2].Text;
 
                    b = CodeCommenataire.Contains("COMM");
                    if (b == true)
                    {
                        this.listView1.Items[i].BackColor = Color.FromArgb(215, 205, 198);
                        //this.Items[i].ForeColor = System.Drawing.Color.Red;
                        this.listView1.Items[i].UseItemStyleForSubItems = false;
                        this.listView1.Items[i].SubItems[1].ForeColor = Color.FromArgb(215, 205, 198);
                        this.listView1.Items[i].SubItems[1].BackColor = Color.FromArgb(215, 205, 198);
                        this.listView1.Items[i].SubItems[2].ForeColor = Color.FromArgb(215, 205, 198);
                        this.listView1.Items[i].SubItems[2].BackColor = Color.FromArgb(215, 205, 198);
                        this.listView1.Items[i].SubItems[0].ForeColor = Color.FromArgb(215, 205, 198);
                        this.listView1.Items[i].SubItems[0].BackColor = Color.FromArgb(215, 205, 198);
                        //Frm_Modification _Modification = new Frm_Modification(this);
                        // MessageBox.Show("OFFRE ligne Comentaire" + " " + numlignecom);
                        // MessageBox.Show("OFFRE ligne Article" + " " + numlignearticle);
                        // MessageBox.Show(this.listView2.Items[i].SubItems[1].ForeColor.ToString());
                        for (int i10 = 0; i10 < this.listView1.Items[i].SubItems.Count; i10++)
                        {
                            if (i10 == 1 || i10 == 0 || i10 == 2)
                            {
 
                            }
                            else
                            {
                                this.listView1.Items[i].SubItems[i10].ForeColor = Color.Black;
                                this.listView1.Items[i].SubItems[i10].BackColor = Color.FromArgb(215, 205, 198);
                            }
                        }
                        //this.Items[i].SubItems[1].Text = "coucou";
                        //this.Items[i].SubItems[1].
                    }
                    else
                    {
                        this.listView1.Items[i].BackColor = Color.FromArgb(215, 205, 198);
                    }
                }
                else
                {
                    bool b = false;
                    string CodeCommenataire = this.listView1.Items[i].SubItems[2].Text;
                    b = CodeCommenataire.Contains("COMM");
                    if (b == true)
                    {
                        this.listView1.Items[i].BackColor = Color.FromArgb(201, 120, 55);
                        //this.Items[i].ForeColor = System.Drawing.Color.Red;
                        this.listView1.Items[i].UseItemStyleForSubItems = false;
                        this.listView1.Items[i].SubItems[1].ForeColor = Color.FromArgb(192, 218, 82);
                        this.listView1.Items[i].SubItems[1].BackColor = Color.FromArgb(192, 218, 82);
                        this.listView1.Items[i].SubItems[2].ForeColor = Color.FromArgb(192, 218, 82);
                        this.listView1.Items[i].SubItems[2].BackColor = Color.FromArgb(192, 218, 82);
                        this.listView1.Items[i].SubItems[0].ForeColor = Color.FromArgb(192, 218, 82);
                        this.listView1.Items[i].SubItems[0].BackColor = Color.FromArgb(192, 218, 82);
                        // Frm_Modification _Modification = new Frm_Modification(this);
                        // MessageBox.Show("OFFRE ligne Comentaire" + " " + numlignecom);
                        // MessageBox.Show("OFFRE ligne Article" + " " + numlignearticle);
                        //  Frm_Modification modif = new Frm_Modification(this.listView2);
                        // MessageBox.Show(this.listView2.Items[i].SubItems[1].ForeColor.ToString());
                        for (int i10 = 0; i10 < this.listView1.Items[i].SubItems.Count; i10++)
                        {
                            if (i10 == 1 || i10 == 0 || i10 == 2)
                            {
 
                            }
                            else
                            {
                                this.listView1.Items[i].SubItems[i10].ForeColor = Color.Black;
                                this.listView1.Items[i].SubItems[i10].BackColor = Color.FromArgb(192, 218, 82);
                            }
                        }
 
                    }
                    else
                    {
                        this.listView1.Items[i].BackColor = Color.FromArgb(192, 218, 82);
 
                    }
 
                }
 
 
            }
 
        }
        private void RechercheClients_Load(object sender, EventArgs e)
        {
 
                System.Data.DataTable Table;
                Bd Bd = new Bd();
                Bd.Open(@" Provider=Microsoft.Jet.OleDB.4.0 ;Data Source=C:\clientpelong\baseclientspelong.mdb");
                Table = Bd.GetTable("Select Distinct Nom from clients WHERE Nom Is Not Null And Not Nom ='' ORDER BY Nom ASC");
 
                for (int i = 0; i < Table.Rows.Count; i++)
                {
                    DataRow drow = Table.Rows[i];
 
                    this.comboBox1.Items.Add(drow["Nom"].ToString());
                    this.comboBox1.Text = "Choisir Nom";
                }
                Bd.Close();
 
 
 
                System.Data.DataTable Table2;
                Bd Bd2 = new Bd();
                Bd2.Open(@" Provider=Microsoft.Jet.OleDB.4.0 ;Data Source=C:\clientpelong\baseclientspelong.mdb");
                Table2 = Bd2.GetTable("Select Distinct Société from clients WHERE Société Is Not Null And Not Société ='' ORDER BY Société ASC");
 
                for (int i = 0; i < Table2.Rows.Count; i++)
                {
                    DataRow drow = Table2.Rows[i];
 
                    this.comboBox2.Items.Add(drow["Société"].ToString());
                    this.comboBox2.Text = "Choisir Société";
                }
                Bd2.Close();
        }
 
 
 
        private ListViewItem CreateListViewItem2(String Num, String Nom, String Prenom, String Societe, String Adresse, String CP, String Ville)
        {
            String[] subitems = new String[7];
            subitems[0] = Num;
            subitems[1] = Nom;
            subitems[2] = Prenom;
            subitems[3] = Societe;
            subitems[4] = Adresse;
            subitems[5] = CP;
 
            subitems[6] = Ville;
 
 
 
 
            ListViewItem lvi = new ListViewItem(subitems);
 
 
            return lvi;
 
        }
 
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.listView1.Items.Clear();
            if (comboBox1.Text != "")
            {
 
                System.Data.DataTable Table;
                Bd Bd = new Bd();
                Bd.Open(@" Provider=Microsoft.Jet.OleDB.4.0 ;Data Source=C:\clientpelong\baseclientspelong.mdb");
                Table = Bd.GetTable("Select * from clients WHERE Nom = " + "'" + comboBox1.Text + "'");
                ListViewItem lvi2;
                for (int i = 0; i < Table.Rows.Count; i++)
                {
                    DataRow drow = Table.Rows[i];
                    lvi2 = CreateListViewItem2(drow["NumClient"].ToString(), drow["Nom"].ToString(), drow["Prenom"].ToString(), drow["Société"].ToString(), drow["Adresse"].ToString(), drow["CP"].ToString(), drow["Ville"].ToString());
                    this.listView1.Items.Add(lvi2);
                    //MessageBox.Show(drow["NumClient"].ToString());
                }
                Bd.Close();
                changercouleur();
            }
        }
 
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            this.listView1.Items.Clear();
            if (comboBox1.Text != "")
            {
 
                System.Data.DataTable Table;
                Bd Bd = new Bd();
                Bd.Open(@" Provider=Microsoft.Jet.OleDB.4.0 ;Data Source=C:\clientpelong\baseclientspelong.mdb");
                Table = Bd.GetTable("Select * from clients WHERE Société = " + "'" + comboBox2.Text + "'");
                ListViewItem lvi2;
                for (int i = 0; i < Table.Rows.Count; i++)
                {
                    DataRow drow = Table.Rows[i];
                    lvi2 = CreateListViewItem2(drow["NumClient"].ToString(), drow["Nom"].ToString(), drow["Prenom"].ToString(), drow["Société"].ToString(), drow["Adresse"].ToString(), drow["CP"].ToString(), drow["Ville"].ToString());
                    this.listView1.Items.Add(lvi2);
                   // MessageBox.Show(drow["NumClient"].ToString());
                }
                Bd.Close();
                changercouleur();
            }
        }
 
        private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
 
            _form3.textBoxClientMail.Text =  this.listView1.SelectedItems[0].SubItems[1].Text;
            //_form3.ShowDialog();
            this.Close();
 
 
        }
    }
}
Merci