1. Set Headers:
// Suppose test is an instance of DataGridView control.
test.Columns[i].Name = "Column Header i";
test.Columns[i].HeaderText = "Column Header i";
test.Rows[j].HeaderCell.Value = "Row Header j";
2. Get the select cell while double clicking mouse.
test.CellDoubleClick += new DataGridViewCellEventHandler(test_doubleClick);
private void test_doubleClick(object sender, DataGridViewCellEventArgs e)
{
Console.WriteLine("{0} been clicked! ", test.Rows[e.RowIndex].Cells[e.ColumnIndex].FormattedValue);
}
3. Add a new row or delete a row
// newRow is an instance of DataGridViewRow or a string array object that contains all the data in row.
test.Rows.Add(newRow);
test.Rows.RemoveAt(index)