我檢查了其他帖子,並建議使EnableHeadersVisualStyles = false
,但只讓我着色他們。我想改變他們的名字,但是當我強制名字如下所示時,他們不會改變。如何更改Windows窗體中DataGridViewColumn的標題?
Products prod = new Products();
DataTable dt = prod.GetTopTenTransactions(Global.Instance.Accounts[0]);
transactionGrid.DataSource = dt;
foreach (DataGridViewColumn cols in transactionGrid.Columns)
{
cols.Width = 70;
}
transactionGrid.ColumnHeadersDefaultCellStyle.BackColor = Color.CadetBlue;
transactionGrid.EnableHeadersVisualStyles = false;
transactionGrid.Columns[0].Name = "ID";
transactionGrid.Columns[1].Name = "TYPE";
transactionGrid.Columns[2].Name = "DATE";
transactionGrid.Columns[3].Name = "AMOUNT";
transactionGrid.Columns[4].Name = "FROM";
transactionGrid.Columns[5].Name = "TO";
transactionGrid.Columns[6].Name = "TELLER ID";
任何幫助將非常感激。