是否可以防止DataGridView中的多行HeaderText? [英] Is it possible to prevent a multi line HeaderText in a DataGridView?

查看:246
本文介绍了是否可以防止DataGridView中的多行HeaderText?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HeaderText 属性的长度达到某个字符限制,并且文本中有空格时,WinForms会自动在标题中插入一个链接中断:

When the length of the HeaderText property reaches a certain character limit and there is a space in the text, WinForms automatically inserts a link break in the header:

我想要的:

+-----------------------+---
| Measurement Value (%) | ...
+-----------------------+---

我所得到的:

+-----------------------+---
| Measurement Value     | ...
|(%)                    |
+-----------------------+---

有足够的空间来显示所有的标题单元格,而不用换行,但无论什么原因,即使我设置了 AutoSizeMode HeaderCell

There is more than enough space to display all header cells without the lines breaks, but for whatever reason it is still inserted even when I set the AutoSizeMode to HeaderCell.

如何防止这些换行符,同时仍然保留空格 HeaderText

How can I prevent these line breaks, while still keeping the spaces in the HeaderText?

推荐答案

ColumnHeadersDefaultCellStyle DataGridView 的code>属性具有名为 WrapMode 的布尔属性。这是默认的。将其设置为false。

The ColumnHeadersDefaultCellStyle property of the DataGridView has a boolean property called WrapMode. This is true by default. Make it false to set the required behaviour.

这篇关于是否可以防止DataGridView中的多行HeaderText?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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