Is there any way to edit column names in a DataGridView?
+2
A:
I don't think there is a way to do it without writing custom code. I'd implement a ColumnHeaderDoubleClick event handler, and create a TextBox control right on top of the column header.
Muxa
2008-09-24 06:43:11
+1
A:
I guess what you want is to edit the HeaderText property of the column:
myDataGrid.TableStyles[0].GridColumnStyles[0].HeaderText = "My Header"
Source: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=186908&SiteID=1
VVS
2008-09-24 06:45:47
+1
A:
You can also edit directly without knowing anything as posted above :
protected void gvCSMeasureCompare_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
e.Row.Cells[0].Text = "New Header for Column 1";
}
mattlant
2008-09-24 06:56:49
+2
A:
You can also do it with myDataGrid.Columns[0].HeaderText = "My Header", but the myDataGrid will need to have been bound to a DataSource.
Spear
2008-09-24 06:59:53