M. rit M. rit - 1 year ago 55
SQL Question

DataGridView and SQL query name

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];

select * from Cards


If you want to change the header text displayed by a DataGridViewColumn you need to use the HeaderText property

dataGridView1.Columns[0].HeaderText = "xxx";