如何使用C#窗体中的组合框计算特定列中的数据量 [英] How to count the amount of data in a specific coloumn using from a combo box in C# windows form

查看:80
本文介绍了如何使用C#窗体中的组合框计算特定列中的数据量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好日子。我正在开发一个Windows窗体贷款申请,我有一个由组合框组成的列,组合框有三个项目或值(已批准,已拒绝,待处理)。我希望能够计算每件物品的数量。例如,我有10个记录(客户),其中三个客户已被批准,3个被拒绝,4个待机使用组合框请我如何计算在datagridview中有多少客户待定,拒绝,批准。



我尝试过的事情:



Good day everyone. I am working on a windows form loan application, I have a column which consist of a combobox, and the combobox has three items or value(Approved,denied,pending). i want to be able to count the amount of each of the items. for example i have 10 records(customers) and three of the customers has been approved,3 denied and 4 pending using the combobox please how can i count how many customers are pending,denied,approved in the datagridview.

What I have tried:

Good day everyone. I am working on a windows form loan application, I have a column which consist of a combobox, and the combobox has three items or value(Approved,denied,pending). i want to be able to count the amount of each of the items. for example i have 10 records(customers) and three of the customers has been approved,3 denied and 4 pending using the combobox please how can i count how many customers are pending,denied,approved in the datagridview. 

推荐答案

首先,您可能不应该直接使用DGV内容 - 您通常会将DGV DataSource设置为集合或表它显示的数据,你可以用它来代替DGV。



但无论如何,你需要通过行,计算哪些行包含匹配元素,有一个显式循环(可能是 foreach )或使用Linq(或Linq方法)的隐式循环)。



我们在这里不能明确:我们不能告诉你这样做它会起作用 - 所有的方法都太多了这可以组织起来,我们无法访问您的代码或数据来查找。哎呀,我们甚至不知道你在ComboBox中存储的是什么,我可以想到可能有六种不同的方法单独做到这一点!



所以首先查看您的数据源,以及它们如何组织显示 - 然后从那里开始工作。
Firstly, you probably shouldn't use the DGV content directly - you would normally have the DGV DataSource set to a collection or table of data which it display, and you would work from that instead of the DGV.

But either way, you need to pass through the rows, counting which rows contain matching elements, either with an explicit loop (for or foreach probably) or with an implicit loop using Linq (or Linq methods).

We can't be explicit here: we can't tell you "do this and it'll work" - there are just too many different ways all this could be organised and we have no access to your code or data to find out. Heck, we don't even know what exactly you are storing in your ComboBox, and I can think of maybe half a dozen different ways to do that alone!

So start by looking at your data sources, and how they are organised for display - then work from there.


这篇关于如何使用C#窗体中的组合框计算特定列中的数据量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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