在DataGridView中的总计行 [英] Totals Row in a DataGridView
问题描述
目前,我正在考虑在datagridview下方添加另一个datagridview,其中包含记录,并显示底部datagridview中的总和。 p>
如果有更好的方法来实现这个任务?
否,需要添加另一个datagridview
解决方案1:请参考此解决方案
解决方案2:如果以上链接不是你真正想要的那样,
您可以尝试手动添加最后一个,总结行,您可以在其中显示所需的信息。例如,您可以尝试执行以下操作:
- 从数据库读取数据并填写System.Data。 DataTable
- 向新创建的DataTable添加一列 - 该列可能设置为
为最后一个摘要行
- 以编程方式添加一个额外的行,其中包含适当的摘要数据
- 将数据绑定到DataGridView控件
- 使用适当的事件,粗体或其他图形不同的摘要
行(具有额外列值
设置为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:
- 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)
这篇关于在DataGridView中的总计行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!