在.NET4 WinForm的列表视图多行的列标题 [英] Multiline column headers in .NET4 WinForm Listview

查看:463
本文介绍了在.NET4 WinForm的列表视图多行的列标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在详细信息视图中的ListView和我已经添加列。我想有列标题高度增加,要么自动换行头文本或允许我使用CRLF指定换行符。

I have a listview in Details view and I have added columns. I would like to have the column header increase in height and either word-wrap the header text or allow me to specify the line break using a CrLf.

这可能使用标准的.NET控件?

Is this possible using the standard .NET controls?

推荐答案

这是困难的,你不能直接控制的列标题的高度。您可以通过给ListView的大字体做到这一点间接。然后,您需要设置OwnerDraw属性为true,并落实DRAWITEM,DrawSubItem和DrawColumnHeader事件。后者可以让你的文字换行。您还需要添加,因此不画大以及字体属性为每个ListViewItem的设置。不愉快的,但并非不可能。

That's difficult, you cannot control the column header height directly. You can do it indirectly by giving the ListView a big Font. You then need to set the OwnerDraw property to true and implement the DrawItem, DrawSubItem and DrawColumnHeader events. The latter lets you word-wrap the text. You will also need to set the Font property for each ListViewItem you add so they are not drawn large as well. Unpleasant but not impossible.

这篇关于在.NET4 WinForm的列表视图多行的列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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