private void comboBox1_DropDown(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count == 1) { DataTable dt = new DataTable(); dt = lc.getBookAssigned(Convert.ToInt32(dataGridView1.SelectedCells[0].Value)); comboBox1.DataSource = dt; comboBox1.ValueMember = dt.Columns[0].ToString(); comboBox1.DisplayMember = dt.Columns[1].ToString(); comboBox1.Text = ""; } else { MessageBox.Show("Please Select any Customer First", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }