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
|
int i = 0;
List<Pompe> pompes = new List<Pompe>();
List<Citerne> citernes = new List<Citerne>();
pompes.Clear();
citernes.Clear();
pompeGridView.Rows.Clear();
pompes = pm.findAll();
citernes = cm.findAll();
// cellule pour le combobox
DataGridViewComboBoxCell[] cb = new DataGridViewComboBoxCell[pompes.Count];
// cellule pour le numéro de pompe
DataGridViewTextBoxCell[] tx0 = new DataGridViewTextBoxCell[pompes.Count];
//cellule pour la designation
DataGridViewTextBoxCell[] tx1 = new DataGridViewTextBoxCell[pompes.Count];
// ligne entière
DataGridViewRow []row=new DataGridViewRow[pompes.Count];
foreach (Pompe c in pompes)
{
cb[i] = new DataGridViewComboBoxCell();
row[i] = new DataGridViewRow();
tx0[i] = new DataGridViewTextBoxCell();
tx1[i] = new DataGridViewTextBoxCell();
// peupler le combobox par la liste des citernes
foreach( Citerne t in citernes )
cb[i].Items.Add(t.type_citerne);
// définit la valeur par défaut de chaque pompe
cb[i].Value = c.citerne.type_citerne;
tx0[i].Value = c.N_pompe;
tx1[i].Value = c.Designation;
// ajouter les 3 cellules à chaque ligne
row[i].Cells.Add(tx0[i]);
row[i].Cells.Add(tx1[i]);
row[i].Cells.Add(cb[i]);
// ajouter la ligna au datagridview
pompeGridView.Rows.Add(row[i]);
i++;
} |
Partager