codebeginnerg
Member
- Joined
- Oct 13, 2014
- Messages
- 6
- Programming Experience
- Beginner
I'm tallying a row in my access database. My databases contain movie company,movies produced by companys and the amount of movies sold. I want to search through the entire database and count each movie the movie company produced. This loads to the listBox automatically and don't need a button to invoke it.Ex:
Company #Movies
20 century 14
DreamWorks 2
LucasFilm 5 etc.
What I'm thinking is created a nested foreach loop and for every movie that is produced by a certain company add it to the listbox
Company #Movies
20 century 14
DreamWorks 2
LucasFilm 5 etc.
What I'm thinking is created a nested foreach loop and for every movie that is produced by a certain company add it to the listbox
C#:
private void tabP3_Click(object sender, EventArgs e)
{
foreach (DataRowView row in bindingSource1.List)
{
foreach (DataRowView row2 in bindingSource1.List)
{
if(((String)row2["Company"]).Equals(row["Movie"]))
{
int count = 0;
string company = ((String)row["Company"]);
count++;
lbCompany.Items.Add((String.Format("{0,5}",company+ " " + count)));
}
}
}
}
Last edited: