Juan
Juan

Reputation: 15715

DataGridView how to have WrapMode = true (multiline cells) and autoadjust width properly?

Apparently, the only way to have multiline cells in a DataGridView is by setting the WrapMode of its DefaultCellStyle to true. My problem is that I also want the width of the column to adjust automatically to the content of the cell, instead of wrapping it by adding line breaks.

Even if I set AutoSizeColumnsMode to AllCells, it will wrap the text instead of making the header bigger. I would also like the row height to adjust automatically. So I don't really want to wrap anything at all. Just adjust width and height to the size of the text.

Upvotes: 2

Views: 7334

Answers (1)

Breccan
Breccan

Reputation: 46

Just set the ColumnHeadersHeightSizeMode property to DataGridViewColumnHeadersHeightSizeMode.DisableResizing. Here's more info;

Upvotes: 3

Related Questions