You can freeze columns and rows in DataGridView (see MSND:
columns[
^],
rows[^]).
You can fill the first frozen column with numbers, first row (header) with letters. Think about the letter numbering as if if were a special number system of 26 digits (see some methods here:
here[
^]).
Update: here you have a sample, assuming that dataGridView1 is your gridview.
public static string ExcelColumnFromNumber(int column)
{
string columnString = "";
decimal columnNumber = column;
while (columnNumber > 0)
{
decimal currentLetterNumber = (columnNumber - 1) % 26;
char currentLetter = (char)(currentLetterNumber + 65);
columnString = currentLetter + columnString;
columnNumber = (columnNumber - (currentLetterNumber + 1)) / 26;
}
return columnString;
}
private void prepareGrid(DataGridView grid, int rows, int cols)
{
grid.ColumnCount = cols;
grid.RowCount = rows;
grid.RowHeadersVisible = true;
grid.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
for (int i = 0; i < rows; i++)
{
grid.Rows[i].HeaderCell.Value = (i+1).ToString();
}
for (int i = 0; i < cols; i++)
{
grid.Columns[i].HeaderCell.Value = ExcelColumnFromNumber(i+1);
}
}
private void Form1_Shown(object sender, EventArgs e)
{
prepareGrid(dataGridView1, 100, 100);
}
Auto-growing the grid is an other topic.