Answered by:
ListView fixed size column headers

Question
-
Hi,
I am using a ListView in its 'Detail' view. I have added several columns there and I want to restrict resizing the column width. I couldn't find a ways to do that; is there any easy way to do that?
Thanks
CJWednesday, September 8, 2010 2:36 AM
Answers
-
Hello CharithJ,
On agree with sendilg, when handling the ColumnWidthChanging of a ListView control, and setting the Cancel property to true will disable listview columnheaders from being resized. But this seems a bug that it can still resize it to a smaller size of width than originally set, see this link:
Also I found an article about Disable Column Resizing in ListView Report Mode, hope this helps too.
Sincerely,
Helen Zhou
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
- Marked as answer by Helen Zhou Tuesday, September 14, 2010 2:09 AM
Thursday, September 9, 2010 9:18 AM
All replies
-
Use ColumnWidthChanging Event to prevent resizing &
set the desired length of the column
private void listView1_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
e.Cancel = true;
e.NewWidth = 100;
}- Proposed as answer by sendilg Wednesday, February 20, 2013 9:53 AM
Wednesday, September 8, 2010 6:06 AM -
Hello CharithJ,
On agree with sendilg, when handling the ColumnWidthChanging of a ListView control, and setting the Cancel property to true will disable listview columnheaders from being resized. But this seems a bug that it can still resize it to a smaller size of width than originally set, see this link:
Also I found an article about Disable Column Resizing in ListView Report Mode, hope this helps too.
Sincerely,
Helen Zhou
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.This response contains a reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you. Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.
- Marked as answer by Helen Zhou Tuesday, September 14, 2010 2:09 AM
Thursday, September 9, 2010 9:18 AM -
I'm currently working on a application and the best workaround for this problem is:
private void listView1_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
{
e.Cancel = true;
e.NewWidth = listView1.Columns[e.ColumnIndex].Width;
}Notify me if there are any bugs since I still have not been able to find any
- Edited by Aleksandar Bog Monday, April 23, 2012 12:00 AM
Monday, April 23, 2012 12:00 AM -
it doesn't work for a listview in winforms if the listview is being populated row by row and the columns are added in the designer for a details view.
Anyone know why?
- Proposed as answer by w10 timebuster Sunday, August 26, 2018 8:17 AM
Sunday, August 26, 2018 8:17 AM