How to fix column width of a list in C # windows form?

I have a listview, I need to fix the column width of the list so that at runtime the user cannot drag the columns and resize ... what is this procedure ?? I searched for all the properties, but none of them helped me solve this problem. it is possible in gridview, but how it will be possible in listview ....

+2
source share
3 answers

The easiest way is to use the ColumnWidthChanging event:

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

Use ObjectListView . This allows not only to fix the width of individual columns, but also to have a minimum and maximum width. He works hard on all cases, including Ctrl-Numpad- +, so they cannot be circumvented.

+1
source

Thanks a lot, I used it in vb.net as

  Private Sub ListView1_ColumnWidthChanging(ByVal sender As Object, ByVal e As System.Windows.Forms.ColumnWidthChangingEventArgs) Handles ListView1.ColumnWidthChanging e.Cancel = True e.NewWidth = ListView1.Columns(e.ColumnIndex).Width End Sub 
0
source

Source: https://habr.com/ru/post/921339/


All Articles