我正在开发一个winform应用程序。我想显示每列最后一行的列总和。该行必须始终可见。
目前,我正在考虑在带有记录的 datagridview 下方添加另一个 datagridview,并在底部 datagridview 中显示总和。
是否有更好的方法来完成这个任务?
最佳答案
不,需要添加另一个datagridview
解决方案1:请引用this solution
解决方案2:如果上面的链接不完全是您想要的,
您可以尝试手动添加最后一个摘要行,在其中可以显示您需要的信息。例如,您可以尝试执行以下操作:
- Read data from database and fill System.Data.DataTable
- Add one column to the newly created DataTable – that column might be set to true for the last, summary, row
- Programmatically add one extra row that contains suitable summary data
- Do the data binding to DataGridView control
- Using appropriate event, bold or otherwise graphically distinct summary row (row that have extra column value set to true)
关于winforms - DataGridView 中的总计行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5591252/