Hy,
i'm working on a application and i'm using a datagridview for displaying 2 columns:example: name of product and quantity. when i select a product and a quantity , pressing an ADD button this datagridview should displaying them...i've tried in this way
private void adaugareGrid()
{
dataGridView1.Refresh();
index = this.dataGridView1.Rows.Count;
dataGridView1.ColumnCount = 2;
dataGridView1.Columns[0].Name = "Detalii Produs";
dataGridView1.Columns[1].Name = "Cantitate";
this.dataGridView1.Rows.Add();
this.dataGridView1.Rows[index].Cells[0].Value = txtModel.Text.ToString();
this.dataGridView1.Rows[index].Cells[1].Value = txtCantitate.Text.ToString();
index++;
}
but after one row is adding then i get an error because of that index..i really don't undersand why.could you please help me?