how to reorder columns in listview?

Thanks

If you click on the liste view, in the properties menu, you can set "Allow Column Reorder" to true. Thats a good place to start.

an idea came to my mind but i dont think it is quite smart.
i can remove the items and get the reference of the removed item and then add the item using AddAt method. i will try that.

i am flabergasted :(
you used to be a hardworker when it came to posting some useful code snippets to my questions :(

I will, I promise :P

It is a Friday evening and i'm having a few drinks before I call it a night. I will take a look at this in the morning. Take the night off! :)

ok that is the deal, then i will increase your reputation points by 5 as well as one more solved threads :D

here is the solution :

Form1.cs :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace ProgrammaticallyReorderListview
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}
		ColumnHeader ch1;
		private void Form1_Load(object sender, EventArgs e)
		{
			ListViewItem item1 = listView1.Items.Add("item1");
			item1.SubItems.Add("subitem1");
			item1.SubItems.Add("subitem2");
			ListViewItem item2 = listView1.Items.Add("item2");
			item2.SubItems.Add("subitem1");
			item2.SubItems.Add("subitem2");

			ch1 = listView1.Columns.Add("column1");
			listView1.Columns.Add("column2");
			listView1.Columns.Add("column3");
		}
		private int columnIndex = 1;
		private void button1_Click(object sender, EventArgs e)
		{
			columnIndex = columnIndex % 3;
			listView1.Columns.Remove(ch1);
			listView1.Columns.Insert(columnIndex, ch1);
			columnIndex++;
		}
	}
}
This question has already been answered. Start a new discussion instead.