Link to home
Start Free TrialLog in
Avatar of Mr_Bach
Mr_Bach

asked on

Combobox in DataGridView

Hi, below is my code, I have column: Condition in table of SQL server, I want when I press button1, the column Condition will be showed like combobox with Items list created in C#.

How Can I do?
private void button1_Click(object sender, EventArgs e)
        {
            String sql = "select * from Main";
            
            try
            {
                SqlConnection c = new SqlConnection(ConnectionString);
                adap = new SqlDataAdapter(sql, c);
                SqlCommandBuilder cb = new SqlCommandBuilder(adap);
                if (c.State == ConnectionState.Closed)
                    c.Open();
                dt = new DataTable();
                adap.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please select Date " + ex.Message);
            }
    
        }

Open in new window

Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

ASKER CERTIFIED SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial