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?
[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.
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 -
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With