Vb.net – How to set row height of a datagridview based on its contents in vb.net

datagridviewvb.net

I want to adjust row height to display entire contents of a cell(column width is fixed). I have one column and many rows in my datagridview.

I used following codes, but I couldn't get required row height

  Me.data.DefaultCellStyle.WrapMode = DataGridViewTriState.True  
  data.AutoResizeRows(DtaGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders)

Best Answer

Set property AutoSizeColumnMode of datagridview to AllCells and check it.

DataGridView.AutoSizeRowsMode Property

try this

  DataGridViewRow row = dataGridView.Rows[0];
  row.Height = 15;

DataGridViewRow.Height Property