Gopal Mahadak

Gopal Mahadak

  • NA
  • 316
  • 154.3k

Datagridview in c#

May 19 2013 5:28 AM
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)