Listing Column Size Listing Column?

I have a WinForm application that has a list. What I want to be able to do is to have the right to change the size (width) of the column each time the window gets larger or smaller. Is it possible? If so, which property is it monitored?

+3
source share
1 answer

ListViewhas a property Columnsthat is a collection containing columns, and each of these columns has the property Width:

var widthOfLastColumn = listView.Columns[ listView.Columns.Count - 1 ].Width;

listView.Columns[ listView.Columns.Count - 1 ].Width = newWidth;

To keep the width of the last column so that it fills the rest of the list, you can add Resizesomething like the following to the Forms event :

var width = 0;
for (int i = 0; i < listView.Columns.Count - 1; i++)
    width += listView.Columns[i].Width;

listView.Columns[ listView.Columns.Count - 1 ].Width =
    listView.ClientSize.Width - width;

, , - .

0

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


All Articles