C# ListView 列宽自动 [英] C# ListView Column Width Auto

查看:47
本文介绍了C# ListView 列宽自动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆