Your requirements are not very clear but I guess you want to customize the row and column headers. The dataGridView is probably one of the best controls to view data in Windows Forms. I will show how to do the following typical requirements would be;
- To show column headers in Title Case or UPPER Case
- Customize the column headers specific names
- Show row numbers on row headers
Code below is in C#
//Show Columns in Title, Lower(textInfo.ToLowerCase) or Upper case textInfo.ToUpperCase
System.Globalization.TextInfo textInfo = new System.Globalization.CultureInfo("en-US", false).TextInfo;
foreach (DataGridViewColumn col in dataGridView.Columns)
{
col.HeaderText = textInfo.ToTitleCase(col.HeaderText);
}
//Customize specific column headers, using name or column index
dataGridView.Columns["number"].HeaderText = "No.";
dataGridView.Columns["quantity"].HeaderText = "Product Quantity";
dataGridView.Columns[0].HeaderText = "Code";
//Set Row headers with numbers
int rowNumber = 1;
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (row.IsNewRow) continue;
row.HeaderCell.Value = "Row " + rowNumber;
rowNumber = rowNumber + 1;
}
dataGridView.AutoResizeRowHeadersWidth(
DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
Reference