1
Answer

Datagridview in c#

Gopal Mahadak

Gopal Mahadak

11y
1.3k
1
Here is the my code to add columns to datagridview runtime :

 DataGridViewComboBoxColumn c5 = new DataGridViewComboBoxColumn();
            c5.HeaderText = "Item_SrNo";
            con.connCheck();
            OleDbCommand cmd = new OleDbCommand("select Item_SrNo from Item_Master", con.cn);
            OleDbDataReader dr = cmd.ExecuteReader();
            while (dr.Read()==true)
            {
                c5.Items.Add(dr["Item_SrNo"].ToString());
            }
            dataGridView1.Columns.Add(c5);
            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("Item_Code", typeof(string)));
            dt.Columns.Add(new DataColumn("Sale_Unit", typeof(string)));
            dt.Columns.Add(new DataColumn("Inventory_Rate", typeof(int)));
            dataGridView1.DataSource = dt;


Here when i press 'enter' in datagridview then comboBox list dropdowns Please Help me...
Answers (1)