开发者

How to wordWrap the text in a column using ObjectListView

开发者 https://www.devze.com 2022-12-26 22:11 出处:网络
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:

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!"

In this post: Multi-line list items on WinForms ListView control? Grammarian said th开发者_如何学Goat you only need to have WordWrap on but I cannot find that option.

Thanks for the help in advanced


Each column has a WordWrap property. Set that to true and the text of that column will wrap.

Remember, the list must be OwnerDrawn for the wrapping to be visible.

EDIT: 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 should have a property like this:

    [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.

0

精彩评论

暂无评论...
验证码 换一张
取 消