how to fix the column width of a listview in c# windows form?

后端 未结 4 766
野性不改
野性不改 2021-01-13 20:43

i have a listview i need to fix the column width of the listview so that at run time user cannot drag the columnheaders and resize it.....what is the procedure?? i have sear

4条回答
  •  一整个雨季
    2021-01-13 20:52

    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;
    }
    

提交回复
热议问题