gpt4 book ai didi

c# - 如果当前行宽已满,WinForm 换行

转载 作者:太空宇宙 更新时间:2023-11-03 22:41:12 25 4
gpt4 key购买 nike

我的 WinForm 中有 DataGridView。我将 AutoSizeColumnsMode 设置为 Fill,因为如果用户调整窗口大小时我不需要空格。

我想要实现的目标。例如,用户在特定单元格中键入一些文本。当文本宽度变为单元格宽度时,文本必须换行。
它可能是怎样的:

|Cell Header|
-------------
|text-text |

|Cell Header|
-------------
|text-text |
|more text |
|on the new |
|line |

我的列可由用户调整大小。所以这个:

|Cell Header|
-------------
|text-text |
|more text |
|on the new |
|line |

可能会这样:

|Cell Header        |
---------------------
|text-text more text|
|on the new line |

我从其他 SO 答案中尝试过的内容:

  • AutoResizeRowsMo​​de 设置为 AllCells - 没有帮助
  • DefaultCellStyle.WrapMode 设置为 True - 没用

我怎样才能真正做到这一点?

编辑:列设置:

enter image description here

编辑#2:

enter image description here enter image description here

最佳答案

设置 RowsDefaultCellStyle.Wrapmode = true 而不是 DefaultCellStyle.WrapMode = true

enter image description here

我对两个网格都使用了默认设置。这是我的设置:

enter image description here

这是代码

enter image description here

关于c# - 如果当前行宽已满,WinForm 换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52126413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com