dataGridView Column header text
Posted on 2005-05-12
I am initialising my dataGridView columns using this code:
string sAry = r.Split(input);
for (int i = 0; i < sAry.Length; i++)
DataColumn dc = new DataColumn();
dc.ColumnName = i.ToString();
dc.Caption = "test123";
dc.DataType = System.Type.GetType("System.Single");
I would expect to see the column header set by the .caption property, however it is displaying the .ColumnName property.
In this example I want all my column headers to display test123.
How do I set the text for column headers? taking into account that the columns are set at run time and more than one column could have the same text.
When setting the columns statically through Visual Studio it is possible to set the HeaderText property for a column, how should I define this through code?