Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
public Form1() { InitializeComponent(); } int buyItem = 0; connection con = new connection(); private void btnOk_Click(object sender, EventArgs e) { dataGridView1.Rows[buyItem].Cells[0].Value = buyItem + 1; dataGridView1.Rows[buyItem].Cells[1].Value = txtItemno.Text; dataGridView1.Rows[buyItem].Cells[2].Value = cbxItem.Text; dataGridView1.Rows[buyItem].Cells[3].Value = cbxBrand.Text; dataGridView1.Rows[buyItem].Cells[4].Value = txtQty.Text; dataGridView1.Rows[buyItem].Cells[5].Value = txtPrice.Text; dataGridView1.Rows[buyItem].Cells[6].Value = txtPoint.Text; dataGridView1.Rows[buyItem].Cells[7].Value =txtLineTotal.Text; buyItem++; }
this line.
dataGridView1.Rows[buyItem].Cells[0].Value = buyItem + 1;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)