如果 DataGridViewTextBoxColumn 的文本太长,如何使其换行?

发布于 2024-10-10 06:39:00 字数 101 浏览 0 评论 0原文

我的问题很简单,但我想不出一个简单的解决方案。假设我有一个 DataGridViewTextBoxColumn。如果文本太长而无法在一行中显示,如何将其分成多行?

My question is simple, but I can not think of an easy solution. Lets say I have a DataGridViewTextBoxColumn. How can I make it break text into several lines if it is too long to be shown in one line?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

神仙妹妹 2024-10-17 06:39:00

您需要创建一个新的 DataGridViewCellStyleWrapMode 属性 设置为“True”,并将其分配给 DataGridViewTextBoxColumnDefaultCellStyle 属性

例如:

DataGridViewCellStyle dgvCellStyle = new DataGridViewCellStyle();
dgvCellStyle.WrapMode = DataGridViewTriState.True;

myDataGridView.Columns[0].DefaultCellStyle = dgvCellStyle;

You need to create a new DataGridViewCellStyle class with the WrapMode property set to "True", and assign this to the DefaultCellStyle property of your DataGridViewTextBoxColumn.

For example:

DataGridViewCellStyle dgvCellStyle = new DataGridViewCellStyle();
dgvCellStyle.WrapMode = DataGridViewTriState.True;

myDataGridView.Columns[0].DefaultCellStyle = dgvCellStyle;
浊酒尽余欢 2024-10-17 06:39:00

DataGridViewTextBoxColumnDefaultCellStyleWrapMode 设置为 true

Set the WrapMode of the DefaultCellStyle of your DataGridViewTextBoxColumn to true.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文