如何在.NET C中的ListView中调整行大小而不调整大小列#

问题描述 投票:-2回答:1

我试图在一行中从列表视图项中获取文本而不调整列大小,类似于文本框属性“Multiline”

在下面的图片中,“Descripcion”列正在向产品描述添加“...”,而不是我希望在一行中包含所有描述。

enter image description here

就像是:

Descripcion         Precio
-------------------|-------
All the description|
in one single row  | 80
-------------------|-------
Another item in one|
single row         | 70
-------------------|-------

我只是尝试过这样的事情:

ListViewItem row = new ListViewItem();
row.ListView.Height = 30;

但是row.Height给我一个例外,任何想法怎么做?

c# .net listview multiline word-wrap
1个回答
1
投票

为了设置高度你可以使用SmallImageList,这是一个例子:

private void SetHeight(ListView listView, int height)
{
    ImageList imgLst = new ImageList();
    imgLst.ImageSize = new Size(1, height);
    listView.SmallImageList = imgLst;
}

还要包装你的Column,你可以使用ObjectListView,它是围绕.NET ListView的开源C#包装器

© www.soinside.com 2019 - 2024. All rights reserved.