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?
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;