I know I can set WrapMode
to true on the DefaultCellStyle
of the RowTemplate
, however this doesn\'t give me the behaviour I want. I am dis
It has worked for me by doing \r\n together with the string.
For example "Hello" + \r\n. It then goes to the next row.
EDIT:
Just saw that this was WinForms. The trick above only works in WPF.
EDIT2:
You can use:
dataGridView1.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
And if you don't want long items wrapping, you just do:
String stringTest = "1234567891";
if (stringTest.Length > 8)
{
stringTest = stringTest.Replace(stringTest.Substring(8), "...");
}
This will add "..." if the String is longer then 8.