Change the Header Names in the DataGridView
Change the Header Names in the DataGridView
If the columns being retrieved from the database do not have meaningful names, we always have the option of changing the header names as shown in this snippet:
C#
private void btnChange_Click(object sender, EventArgs e)
{
DataGridview1.Columns[0].HeaderText = "Header1";
DataGridview1.Columns[1].HeaderText = "Header2";
}
VB.NET
Private Sub btnChange_Click(ByVal sender As Object, ByVal e As EventArgs)
DataGridview1.Columns(0).HeaderText = "Header1"
DataGridview1.Columns(1).HeaderText = "Header2"
End Sub