I am trying to create a DataTable
and bind it to a DataGridView
. It works, but I can't set columns headers via the Caption
property. It displays headers using the ColumnName
("City") instead. MSDN says that
"You can use the Caption property to display a descriptive or friendly
name for a DataColumn."
Here is my code:
DataColumn dc = new DataColumn("City", typeof(string));
dc.Caption = "Город";
DataTable dt = new DataTable();
dt.Columns.Add(dc);
DataRow row = dt.NewRow();
row["City"] = "Moscow";
dt.Rows.Add(row);
datagridview.DataSource = dt;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…