Click here to Skip to main content
16,019,593 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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. 
Posted
Updated 24-May-19 22:27pm
Comments
Richard MacCutchan 25-May-19 4:23am    
Examine each row and test what status the combobox contains. Count the items from that information.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900