我有一个 dataGridView,其中大约有 30 行,最后一行包含该特定列中所有单元格的总和。现在我想卡住具有总和的最后一行,同时仍然允许剩余的行滚动。
dataGridViewPaymentsReceived.Rows[dataGridViewPaymentsReceived.Rows.Count-1].Frozen = true;
The above code freezes the entire dataGridView and doesn't allow me to scroll on it. Can anyone suggest me a good way to keep the last row displayed all the time even when I scroll on the dataGridView?
最佳答案
最简单的解决方案是在第一个 DataGridView 的正下方创建第二个。然后在每次第一个数据网格绑定(bind)到数据时,用您希望显示的单行手动填充它。
为了让它看起来完全无缝,不要忘记隐藏第二个数据网格中的列标题:
dataGridView2.ColumnHeadersVisible = false;
参见 this answer了解更多信息。
关于c# - 如何使 Windows 窗体上的 dataGridView 中的最后一行始终显示,同时仍允许剩余行滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18256581/