DataGridView Row Height Autosize
I am using a DataGridView
in C# .NET 3.5 and I want the height of all rows set to AutoSize
.
I set WrapMode = true
but am still not getting the height 开发者_高级运维to autosize.
DataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
See http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.autosizerowsmode.aspx
if you want to change only for particular row :
int j = Rowindex;
datagridview1.AutoResizeRow(j, DataGridViewAutoSizeRowMode.AllCells);
DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
is a better choice, if you want to keep same width of columns.
Setting the "DefaultCellStyle" -> WrapMode = true in Design, easy!
精彩评论