winforms - DataGridView 中的总计行

标签 winforms datagridview

我正在开发一个winform应用程序。我想显示每列最后一行的列总和。该行必须始终可见。

目前,我正在考虑在带有记录的 datagridview 下方添加另一个 datagridview,并在底部 datagridview 中显示总和。

是否有更好的方法来完成这个任务?

最佳答案

不,需要添加另一个datagridview

解决方案1:请引用this solution

解决方案2:如果上面的链接不完全是您想要的,

您可以尝试手动添加最后一个摘要行,在其中可以显示您需要的信息。例如,您可以尝试执行以下操作:

  1. Read data from database and fill System.Data.DataTable
  2. Add one column to the newly created DataTable – that column might be set to true for the last, summary, row
  3. Programmatically add one extra row that contains suitable summary data
  4. Do the data binding to DataGridView control
  5. 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/

相关文章:

wpf - 一个组合框,提供可调整大小的文件名完成列表和带有历史记录的下拉列表

c# - 复制 RDLC 报告文本并粘贴到记事本中

.net - 使用 concat() 从 mysql 存储过程检索并绑定(bind)到 datagridview 时出错

arrays - 在 VB.NET 中将多维数组分配给 DataGridView

WPF DataGrid如何获取ItemsSource何时更新

c# - 设置 DataGridView.DataSource 后获取空白行

c# - 正确舍入财务数据

C# 在 Control 的生命周期中 Site (ISite) 不为空?

c# - 有没有办法创建一个共同的事件?

c# - 隐藏 DataGridViewImageColumn 中的图像