G
Guest
Hi,
How can I adjust the row height in a grid with multiple lines in a row?
Thank you
Christian.
How can I adjust the row height in a grid with multiple lines in a row?
Thank you
Christian.
RobinS said:This is from "Pro .Net 2.0 Windows Forms and Custom Controls in VB2005"
by Matthew MacDonald.
You set the columns that you want to wrap. Then you set the column width.
Then you use automatic row resizing to heighten the row to fit all the text.
Here's an example that ensures you can always see the full description text.
The Description column is set to use DataGridViewAutoSizeColumnMode.Fill,
and the automatic row size adjusts the row height as necessary.
Dim colDesc as DataGridViewColum = dataGridView1.Columns("Description")
'Give it as much width as possible
colDesc.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
'Wrap to fit the bounds of the column
colDesc.DefaultCellStyle.WrapMode = DataGridViewTriState.True
'Use row autosizing to show all the text
dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells
If you use AllCell instead of DisplayedCells, it will do all of the cells in
the grid; this
will result in more lethargic performance.
I think you can also use DataGridView styles. If this doesn't work, repost
and
hopefully if I don't have time to research it, someone else will.
Good luck.
Robin S.