C# ListView Column Width Auto

后端 未结 10 1112
傲寒
傲寒 2020-11-28 07:04

How can I set the column width of a c# winforms listview control to auto. Something like width = -1 / -2 ?

10条回答
  •  清酒与你
    2020-11-28 07:56

    If you have ListView in any Parent panel (ListView dock fill), you can use simply method...

    private void ListViewHeaderWidth() {
            int HeaderWidth = (listViewInfo.Parent.Width - 2) / listViewInfo.Columns.Count;
            foreach (ColumnHeader header in listViewInfo.Columns)
            {
                header.Width = HeaderWidth;
            }
        }
    

提交回复
热议问题