I came across this simple but interesting problem posted in one of the community forums. The problem was: How to restrict the user to resize the Listview columns in a windows application?
Well, the first the obvious direction was to use ColumnWidthChanging event. But to my surprise, it did not do the trick. After some more googling, I found that this was a known bug to Microsoft which they promised to take care in VS 2008 but haven’t.
In between, a possible workaround would be to cancel the event, and set the old width again.
private void listView1_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
//Keep the width not changed.
e.NewWidth = this.listView1.Columns[e.ColumnIndex].Width;
//Cancel the event.
e.Cancel = true;
}
Be First to Comment