datagridview - 如何在datagridview的最后一行下获得灰色区域的高度?
解决方案
This appears fairly straight forward.
Create an (accumulator) variable
totalDisplaySize
to keep track of the total height of the “displayed” rows plus the column height.Start a loop at the “First Displayed Row Index” and end at the last row.
- Add each displayed row height to the accumulator
totalDisplaySize.
- Return the grids height – (minus)
totalDisplaySize.
Adding a check in the loop to see if the totalDisplaySize
becomes greater than the grids height, may look something like…</p>
private int GetUnusedHeight() {
int totalDisplaySize = dataGridView1.ColumnHeadersHeight;
for (int i = dataGridView1.FirstDisplayedScrollingRowIndex; i < dataGridView1.RowCount; i++) {
totalDisplaySize += dataGridView1.Rows[i].Height;
if (totalDisplaySize >= dataGridView1.Height)
return 0;
}
return dataGridView1.Height - totalDisplaySize;
}
推荐阅读
- azure - 如何在 Azure 数据工厂管道中复制整个架构/数据库?
- oracle-data-integrator - ODI 12 命令startscen.cmd 不返回代码
- java - JavaFX TextArea onSelectionChange 方法
- kotlin - 如何使用 kontlinx.serialization 序列化泛型类?
- php - Util.php 第 206 行中的 ErrorException:不推荐使用函数 create_function()
- java - 仅使用简单的分布式缓存时,如何为 Ignite 打开最少数量的端口?
- file-upload - 测试自动化 - Katalon - 扫描病毒时上传文件
- c++ - 将递归更改为更便宜的东西
- mysql - 如何将主键设为varchar
- css - 如何使用每页显示一行的 Material UI 表?