[英]How to resize rows in a datagridview so that they fill the entire control and all have the same height
将DataGridView
的ScrollBars
属性设置为None
并使用此代码设置行的大小:
foreach (DataGridViewRow row in dataGridView1.Rows)
{
row.Height = (dataGridView1.ClientRectangle.Height - dataGridView1.ColumnHeadersHeight) / dataGridView1.Rows.Count;
}
还使用此代码来处理大小调整:
private void dataGridView1_SizeChanged(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
row.Height = (dataGridView1.ClientRectangle.Height - dataGridView1.ColumnHeadersHeight) / dataGridView1.Rows.Count;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.