private void plat_grid_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { categorie_box.SelectedItem = ""; DataGridViewRow row = this.plat_grid.Rows[e.RowIndex]; nom_plat_box.Text = row.Cells["nom_plat"].Value.ToString(); prix_plat_box.Text = row.Cells["prix"].Value.ToString(); code_plat_box.Text = row.Cells["id_plat"].Value.ToString(); disponible_combo.SelectedItem = row.Cells["Disponibilité"].Value.ToString();; int codeCat = int.Parse(row.Cells["id_categorie"].Value.ToString()); categorie_box.SelectedItem = db.Categorie_Code_Nom(codeCat);//remember that 'Categorie_Code_Nom' return the name of the categorie's code given in input } }