private void add_Columns_Rows() { //setup the columns to be added. dataGridView1.ColumnCount = 5; //Set the columns name dataGridView1.Columns[0].Name = "ID"; dataGridView1.Columns[1].Name = "Item"; dataGridView1.Columns[2].Name = "Price"; dataGridView1.Columns[3].Name = "Quantity"; dataGridView1.Columns[4].Name = "Sub-Total"; //Set a value to be added in a row //adding rows in the datagridview dataGridView1.Rows.Add(row); //Set a value to be added in a row //adding rows in the datagridview dataGridView1.Rows.Add(row); //Set a value to be added in a row //adding rows in the datagridview dataGridView1.Rows.Add(row); //Set a value to be added in a row //adding rows in the datagridview dataGridView1.Rows.Add(row); }
private void Form1_Load(object sender, EventArgs e) { //displaying the columns and rows. add_Columns_Rows(); }