Click here to Skip to main content
15,921,837 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i want to populate a row that added programmatically in datagridview with data (sql) or (access database) ..
the code used to add a row programmatically is :
C#
        DataGridViewColumn d1 = new DataGridViewComboBoxColumn();
            DataGridViewColumn d2 = new DataGridViewComboBoxColumn();
            DataGridViewColumn d3 = new DataGridViewTextBoxColumn();
            DataGridViewColumn d4 = new DataGridViewTextBoxColumn();
            DataGridViewColumn d5 = new DataGridViewTextBoxColumn();
            DataGridViewColumn d6 = new DataGridViewTextBoxColumn();
            DataGridViewColumn d7 = new DataGridViewTextBoxColumn();

            d1.HeaderText = "barcode";
            d2.HeaderText = "product name";
            d3.HeaderText = "product type";
            d4.HeaderText = "product price";
            d5.HeaderText = "product amount";
            d6.HeaderText = "product balance";
            d7.HeaderText = "note";

            if (this.dataGridView1.Columns.Count == 0)
            {

                dataGridView1.Columns.AddRange(d1, d2, d3, d4, d5, d6, d7);
            }

            dataGridView1.Rows.Add(1);

}
Posted
Updated 13-Jan-15 9:47am
v2
Comments
Zoltán Zörgő 17-Jan-15 6:53am    
Any progress?

1 solution

Read this short tutorial: http://www.dotnetperls.com/datagridview-tutorial[^], or consult MSDN[^].
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 13-Jan-15 19:46pm    
Sure, a 5.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900