C# ListView 列宽自动 [英] C# ListView Column Width Auto
问题描述
如何将 c# winforms listview
控件的列宽设置为自动.像宽度 = -1/-2 之类的东西?
How can I set the column width of a c# winforms listview
control to auto. Something like width = -1 / -2 ?
推荐答案
您给出了答案:-2 将根据列标题中的文本长度自动调整列大小,-1 将自动调整为列中最长的项目.全部根据 MSDN.请注意,在 -1 的情况下,您需要在添加项目后设置列宽.因此,如果您添加一个新项目,您还需要根据 ListView
控件中的数据分配要自动调整大小的列(或多列)的宽度属性.
You gave the answer: -2 will autosize the column to the length of the text in the column header, -1 will autosize to the longest item in the column. All according to MSDN. Note though that in the case of -1, you will need to set the column width after adding the item(s). So if you add a new item, you will also need to assign the width property of the column (or columns) that you want to autosize according to data in ListView
control.
这篇关于C# ListView 列宽自动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!