如何根据 vb.net 中的内容设置 datagridview 的行高
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30507972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to set row height of a datagridview based on its contents in vb.net
提问by Shreyas Bhat
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.
我想调整row
height
以显示单元格的全部内容(列宽是固定的)。我的数据网格视图中有一列和多行。
I used following codes, but I couldn't get required row height
我使用了以下代码,但无法获得所需的行高
Me.data.DefaultCellStyle.WrapMode = DataGridViewTriState.True
data.AutoResizeRows(DtaGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders)
回答by Pradnya Bolli
Set property AutoSizeColumnModeof datagridview to AllCellsand check it.
将datagridview 的属性AutoSizeColumnMode设置为AllCells并检查它。
DataGridView.AutoSizeRowsMode Property
DataGridView.AutoSizeRowsMode 属性
try this
尝试这个
DataGridViewRow row = dataGridView.Rows[0];
row.Height = 15;
回答by Abdullah Ishtiwy
To change the height of the rows you must to make a change to the specific row (On by On) like this
要更改行的高度,您必须像这样更改特定行(On by On)
For i = 0 To DataGridView1.Rows.Count - 1
Dim r As DataGridViewRow = DataGridView1.Rows(i)
r.Height = 50
Next
回答by Aleemuddin Siddiqui
You can use this instead:
您可以改用它:
For i=0 to DataGridView1.Rows.Count-1
DataGridView1.Rows(i).Height=50
Next
It will consume less time and coding lines
它将消耗更少的时间和编码线