如何计算DataGrid的列值并将其传递到VB.NET中的文本框 [英] How to count column values of a DataGrid and pass it to a textbox in VB.NET

查看:88
本文介绍了如何计算DataGrid的列值并将其传递到VB.NET中的文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用VB.NET和WPF.

在WPF窗口中,我在Load事件中显示一个DataGrid.在Load事件本身中,我需要从单个DataGrid列中计算总计,然后将其添加到同一页面的文本框中.

我的页面看起来像这样:

Hi all,

I am using VB.NET and WPF.

In a WPF window, I am showing a DataGrid in the Load event. In the Load event itself, I need to count the grand total amount from a single DataGrid column and add it to a textbox in the same page.

My page looks like this:

MY DATAGRID

   Item          Quantity       Total 
   ``````        ````````       `````
   Shirt            2           200
   Pant             1           500
   Tie              -            -
   Belt             2           100

  
MY TEXTBOX   --->  Grand Total amount : - 800



如果iam从((Total Column))DTG进行计数,该怎么办
并将其添加并显示在我的((GRAND TOTAL AMOUNT))文本框中.

在此先感谢

Naveen .....



How can I do that if iam counting from a ((Total Column )) DTG
and adding it and showing it in my (( GRAND TOTAL AMOUNT)) TEXTBOX.

Thanks in advance

Naveen.....

推荐答案

您最合理的方法是在数据源上使用SQL进行总计.但是,您可以遍历行,然后根据需要在代码中添加列中的值,这很容易.
Your most logical way of doing this is to use SQL on the data source to get a total. However, you can iterate over the rows, then add the values from the column in code if you want, that''s an easy enough task.


这篇关于如何计算DataGrid的列值并将其传递到VB.NET中的文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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