我使用了带换行符的 DataGridView,但由于某种原因出现了问题。 这是代码:
this.übersetzerDataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
this.übersetzerDataGridView.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True;
结果如下:
我做错了什么?
最佳答案
[已解决]经过多方搜索,我终于找到了解决方案。
通过在相关列中使用 Fill 值。
The column width adjusts so that the widths of all columns exactly fills the display area of the control.
this.übersetzerDataGridView.Columns[2].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
this.übersetzerDataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
this.übersetzerDataGridView.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
结果如下:
非常感谢。
关于C# - DataGridView 在 Cell 中换行文本但没有空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43455093/