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:

private void btnChange_Click(object sender, EventArgs e)
DataGridview1.Columns[0].HeaderText = "Header1";
DataGridview1.Columns[1].HeaderText = "Header2";


Private Sub btnChange_Click(ByVal sender As Object, ByVal e As EventArgs)
DataGridview1.Columns(0).HeaderText = "Header1"
DataGridview1.Columns(1).HeaderText = "Header2"
End Sub


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: