Their is difficulty in changing the name of the columnheader of list view constantly by using the loop in button click method...Is their any way to change the textname by using loop??? :S

Try this.

I don't know why you would want to do this, but w/e.

foreach (ColumnHeader LWC in listView1.Columns)
            {
                LWC.Text = "LWS";
            }

This will change all columns in the ListView to LWS.

If this isn't what you wanted please clarify.

Please mark as solved if solved.

Hey finito thanx for the zillion for responding to my problem.. thanq again.

Hey finito it changes all the column header suppose i have 3 column header
e.g.
Name | age | sex |
and what if to change above to as below
email id | phone | address |
your mentioned code changes all column header to the same text name I want to change it differently thanx again!

string[] i = new string{ "Email ID", "Phone", "Address" };
      int k = 0;
      foreach (ColumnHeader LWC in listView1.Columns)
            {
                LWC.Text = i[k];
                k++;
            }

As I mentioned earlier:

This will change all columns in the ListView to LWS.

it may be more economical to just do:

columnHeader1.Text = "Email ID";
columnHeader2.Text = "Phone";
columnHeader3.Text = "Address";

Now I'm laughing at myself I had tried you're last suggestion last time it was and error but now it works:-O ... Thanx again for the help finito.

Just curious which one did you go with?

Last one...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.