Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set DataGridView textbox column to multi-line?

How to let "DataGridViewTextBoxColumn" in DataGridView supports Multiline property?

like image 922
Wahid Bitar Avatar asked Oct 13 '09 12:10

Wahid Bitar


2 Answers

You should be able to achieve this by setting the WrapMode of the DefaultCellStyle of your DataGridViewTextBoxColumn to true.

like image 78
Tim S. Van Haren Avatar answered Oct 07 '22 04:10

Tim S. Van Haren


I have found that there are two things that you need to do, both in the designer, to make a text cell show multiple lines. As Tim S. Van Haren mentioned, you need to set WrapMode of the DefaultCellStyle of your DataGridViewTextBoxColumn to true. And although that does make the text wrap, it doesn't make the row expand to show anything beyond the first line. In addition to WrapMode, the AutoSizeRowsMode of the DataGridView must be set to the appropriate DataGridViewAutoSizeRowsMode enumeration value. A value such as DataGridViewAutoSizeRowsMode.AllCells allows the cell to expand vertically and show the entire wrapped text.

like image 37
Tom Faust Avatar answered Oct 07 '22 03:10

Tom Faust