Search code examples
c#listviewwidthfixed

How to fix the column width of a listview in c# Windows Form?


I have a listview, and I need to fix the column width of the listview so that at runtime user cannot drag the column headers and resize it... What is the procedure?? I have searched all the properties but none of them help me out to solve this pbm... This is possible in gridview but how will it be possible in listview?


Solution

  • The easiest way is to use ColumnWidthChanging event:

    private void listView_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e)
    {
        e.Cancel = true;
        e.NewWidth = listView.Columns[e.ColumnIndex].Width;
    }