问题描述
当 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!