How to rename the columns’ headers of datagridview dynamically?
until now I used this code:
dataGridView1.Columns[0].HeaderText = "my_title";
the problem is that Columns[0] might change with time..
How can I iterate on all the Columns Headers and do something like
if (Column.HeaderText=="customer_id") {Column.HeaderText="my_title"} ?
Just use a foreach to iterate over all columns:
This of course would only change the header text for the one column.
If you want to set custom header text for multiple columns you could use a
switchinstead of theif.