开发者

DataGridView Row Height Autosize

开发者 https://www.devze.com 2023-01-20 14:06 出处:网络
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.AutoSizeRo

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号