在DataGridView中的总计行 [英] Totals Row in a DataGridView

查看:313
本文介绍了在DataGridView中的总计行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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

如果有更好的方法来实现这个任务?

解决方案

否,需要添加另一个datagridview



解决方案1:请参考此解决方案



解决方案2:如果以上链接不是你真正想要的那样,



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



  1. 从数据库读取数据并填写System.Data。 DataTable

  2. 向新创建的DataTable添加一列 - 该列可能设置为
    为最后一个摘要行

  3. 以编程方式添加一个额外的行,其中包含适当的摘要数据

  4. 将数据绑定到DataGridView控件

  5. 使用适当的事件,粗体或其他图形不同的摘要
    行(具有额外列值
    设置为true的行)



I am developing a winform application application. I wanted to show sum of columns in last row of each column. This row must always be visible.

At moment I am thinking about adding another datagridview just beneath my datagridview with records, and would show the sum in that bottom datagridview.

If there is a better way to achieve this task?

解决方案

No, need of adding another datagridview

Solution 1: Please refer to this solution

Solution 2: If the above link is not exactly what you want then,

You can try to manually add last, summary, row in which you can display information that you need. For example, you can try to do the following:

  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)

这篇关于在DataGridView中的总计行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆