如何在DataGridView中总计总量 [英] How to sum total amount in DataGridView
本文介绍了如何在DataGridView中总计总量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在中累计总金额DataGridView
How to Sum total amount in DataGridView
Column1 Column2 Column3 Column n TOTAL
500 100 300 900
200 75 100 375
100 25 150 275
400 50 225 675
500 100 450 1050
请告诉我如何总计。
Please tell me how to sum total.
推荐答案
如果你可以从表中获取数据,请使用:
If you can get the data from table, use this:
SELECT Column1, Column2, Column3, ColumnN, (Column1 + Column2 + Column3 + ColumnN) AS TOTAL
FROM TableName
不要忘记使用 COALESCE() [< a href =http://msdn.microsoft.com/en-us/library/ms190349%28v=sql.90%29.aspxtarget =_ blanktitle =New Window> ^ ]功能。为什么?阅读它。
Do not forget to use COALESCE()[^] function. Why? Read it.
请参阅解决方案1,考虑到我对它的评论。你走错了方向。
我建议你学习和分析以下架构模式的适用性(http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science) [ ^ ]):
MVVM - 模型视图视图模型, 注意这些架构的动机。如果您了解它,您将能够创造更好的设计理念。
http://en.wikipedia.org/wiki/Model_View_ViewModel [ ^ ],
MVC - 模型 - 视图 - 控制器,
http:// en .wikipedia.org / wiki /模型 - 视图 - 控制器 [ ^ ]),
MVA - 模型 - 视图 - 适配器,
http://en.wikipedia.org/wiki/Model-view-adapter [ ^ ],
MVP - Model-View-Presenter,>
http://en.wikipedia.org/wiki/Model-view-presenter [ ^ ]。
-SA
Please see the Solution 1, taking into account my comment to it. You were moving in wrong direction.
I suggest you learn and analyze applicability of the following architectural patterns (http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)[^]):
MVVM — Model View View Model, Pay attention for the motivation of those architectures. If you understand it, you would be able to create better design ideas.
http://en.wikipedia.org/wiki/Model_View_ViewModel[^],
MVC — Model-View-Controller,
http://en.wikipedia.org/wiki/Model-view-controller[^]),
MVA — Model-View-Adapter,
http://en.wikipedia.org/wiki/Model–view–adapter[^],
MVP — Model-View-Presenter,
http://en.wikipedia.org/wiki/Model-view-presenter[^].
—SA
这篇关于如何在DataGridView中总计总量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文