如何使用ObjectListView来换行一列文 [英] How to wordWrap the text in a column using ObjectListView
问题描述
例如我有一个很大的一句话:
For example I have a big sentence:
我喜欢吃馅饼,并有周围的房子开心一整天! 我希望它看起来是这样的:
"I like to eat pie and have fun around the house all day long!" And I want it to appear like this:
我喜欢吃馅饼和有 房子周围的所有乐趣 整天!
"I like to eat pie and have fun around the house all day long!"
在这篇文章:<一个href="http://stackoverflow.com/questions/1673963/multi-line-list-items-on-winforms-listview-control">http://stackoverflow.com/questions/1673963/multi-line-list-items-on-winforms-listview-control文法说,你只需要拥有自动换行上,但我无法找到该选项。
In this post: http://stackoverflow.com/questions/1673963/multi-line-list-items-on-winforms-listview-control Grammarian said that you only need to have WordWrap on but I cannot find that option.
感谢先进的帮助
推荐答案
每列都有一个自动换行
属性。其设置为真
和列的文本将换行。
Each column has a WordWrap
property. Set that to true
and the text of that column will wrap.
记住,列表必须OwnerDrawn为包装可见。
Remember, the list must be OwnerDrawn for the wrapping to be visible.
编辑:今天我又看了一下,和你说的很对 - 该属性已经不见了!我不知道它已经消失到。我敢肯定,它曾经是有:(
I looked again today, and you are quite right -- that property has gone! I have no idea where it has vanished to. I'm sure it used to be there :(
OLVColumn
应该有这样的特性:
[Category("Behavior - ObjectListView"),
Description("Draw this column cell's word wrapped"),
DefaultValue(false)]
public bool WordWrap {
get { return wordWrap; }
set {
wordWrap = value;
if (wordWrap) {
this.Renderer = new BaseRenderer();
((BaseRenderer)this.Renderer).CanWrap = true;
((BaseRenderer)this.Renderer).UseGdiTextRendering = false;
} else {
this.Renderer = null;
}
}
}
private bool wordWrap;
将在,你就可以自动换行的列的内容。
Put that in, and you'll be able to word wrap your column's contents.
这篇关于如何使用ObjectListView来换行一列文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!