Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8070793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:30:39+00:00 2026-06-05T13:30:39+00:00

How to rename the columns’ headers of datagridview dynamically? until now I used this

  • 0

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"} ?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:30:40+00:00Added an answer on June 5, 2026 at 1:30 pm

    Just use a foreach to iterate over all columns:

    foreach(DataGridViewColumn column in dataGridView1.Columns)
    {
        if (column.HeaderText=="customer_id") { column.HeaderText="my_title" }
    }
    

    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 switch instead of the if.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to rename my DataTable column names. I tried this: dt.Columns[8].ColumnName = "regnum";
I would like to rename a large number of columns (column headers) to have
I need to rename columns in my MySQL table using PHP. This is made
I'm trying to rename the columns. The syntax should be the column name between
We sometimes write dataport scripts that rename tables or columns and have other complex
I just need to rename JQgrid column dynamically as per user selection from a
I want to rename the timestamp columns defined in timestamp.rb . Can the methods
I want to execute a query in which I rename one of the columns
I want to rename some random columns of a large data frame and I
If I rename SQLite Tables/Columns/Rows after indices have been created, will the old indices

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.