I'm new to using the C#/.NET programming Language and I have created a DataGridView for adding, editing and deleting records.
I am using Visual Studio 2010 for coding. I have put in an unbound column for row number and have this method for displaying the auto generated row numbers.
private void dataGridView1_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
row.Cells["rownumber"].Value = row.Index + 1;
}
e.Row.Cells["min_bracket"].Value = 0;
e.Row.Cells["max_bracket"].Value = 0;
e.Row.Cells["tax_percent"].Value = 0;
e.Row.Cells["add_amount"].Value = 0;
}
This does work when inserting values into the datagrid but does not show any numbers in the rownumber column when retrieving values.
How do I get to have auto generated numbers in the header instead of having to create an unbound column like I have that works when inserting rows and retrieving records?