Reputation: 1733
I have used the DataGridView with the line break but for some reason something is wrong. This is the code:
this.übersetzerDataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
this.übersetzerDataGridView.RowsDefaultCellStyle.WrapMode = DataGridViewTriState.True;
Here is the result:
What am I doing wrong?
Upvotes: 4
Views: 6050
Reputation: 49
Since @Michael posted his code in German and it might make some people confused (just like me) this did the work for me -
Add the following code to the RowValidated event in your DataGridView
Private Sub DGV_RowValidated(sender As System.Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV_I.RowValidated
DGV_I.DefaultCellStyle.WrapMode = DataGridViewTriState.True
DGV_I.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders
DGV_I.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
End Sub
The result -
Upvotes: 1
Reputation: 1
Enable wrap mode for the column in question:
dgv.Columns["dtComment"].DefaultCellStyle.WrapMode = DataGridViewTriState.True;
Set AutosizeRowsMode to AllCells
Upvotes: -1
Reputation: 1733
[SOLVED] After much searching, I finally found the solution.
By using Fill value in the column in question.
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;
Here is the result:
Thanks a lot.
Upvotes: 7