I have a function that gets all the data from database (also the column names) and shows it in a DataGridView.
The problem is that the DataGrid show also the column name. How can I edit the columns name? I already tried
dataGridView1.Columns[0].Name = "xxx";
without success.
private void PriceChange_Load(object sender, EventArgs e)
{
DbCards d = new DbCards();
dataGridView1.DataSource = d.GetAllcards().Tables[0];
}
GetAllcards()
is select * from Cards
.
如果要更改 DataGridViewColumn 显示的标题文本,则需要使用HeaderText属性
dataGridView1.Columns[0].HeaderText = "xxx";
改为设置dataGridView1.Columns[0].HeaderText
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.