如何在DataGridView中乘以列? [英] How To Multiply Columns in DataGridView?

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

问题描述

你好朋友,
我一直在尝试在VB 2010中建立数据库.
我有一个名为:Sales的表,其中包含以下列,
价格,数量,税金和金额.
我想做的是,在输入上述字段后,立即将价格,数量和税项数据乘以金额列.
我已经使用MSSql创建了一个数据库.
当我尝试将查询添加到默认的TableAdapter时,它给出了称为Schema错误的信息.
因此,我添加了一个新的适配器和一个查询,
从销售中选择价格,税收,数量,价格*税额*数量作为数量
它已正确执行,但是我无法使其与表一起使用.
我该怎么办?

Hello friends,
I have been trying to set up a database in VB 2010.
I have a table Called: Sales, which contains following columns,
Price, Quantity, Tax and Amount.
What I wish to do is, Multiply, Price, Quantity and Tax data to Amount Column instantly as the above fields are entered.
I have created a database using MSSql.
When I try adding a query to the default TableAdapter, it gives something called as Schema error.
So, I added a new Adapter and a query,
SELECT PRICE, TAX, Quantity, PRICE*TAX*Quantity AS Amount FROM sales
It got executed correctly, but I am unable to get it working with the table.
What should i do?

推荐答案

一种方法是使用 ^ ]事件,然后将计算结果放在那里.

如果将数据表用作基础数据源,则还可以考虑在数据表中添加计算列.
One way is to use CellValidated[^] event and place your calculations in there.

If you use a data table as underlying data source, you could also consider adding a computed column in the data table.


请参考以下线程:

本文演示了如何在GridView中开发客户端计算,并且可以在DB端配置计算表达式:
GridView中数据库驱动的客户端计算 [ ^ ]

使用JavaScript/JQuery:
使用JavaScript/JQuery计算GridView总数 [ ^ ]

如何为gridview列添加客户端计算 [ ^ ]
在GridView控件的页脚中显示总计" [ ASP.NET的GridView示例:在页脚中显示摘要数据 [在GridView的页脚中显示摘要信息 [在ASP.net C#中计算Gridvew中的总价值 [ ^ ]

希望你能从中得到一些帮助!
Please refer following threads:

This article demonstrates how to develop client side calculations in a GridView, and calculation expressions are configurable at the DB side:
Database driven client side calculations in GridView[^]

Using JavaScript/JQuery:
Calculating GridView total using JavaScript/JQuery[^]

How To Add client side calculation for gridview column[^]
Display Sum Total in the Footer of the GridView Control[^]

GridView Examples for ASP.NET: Displaying Summary Data in the Footer[^]
Displaying Summary Information in the GridView''s Footer[^]

Check similar discussion on following link:
Calculate Total Value In Gridvew In ASP.net C#[^]

Hope you get some needful from it!


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

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