Im trying to create a voting program that count how many people have voted already. I have a datagridview with 5 columns. Column 1 is Name,Column 2 is yellow,column 3 is black,column 4 is unknown and column 5 is voted. In column 1 i have 50 people and the people are already assign a 1 if they are yellow, white or unknown. when they come in to vote their name will be find in the database and when they finish vote column 5 will have 1.
0 is equal to not voted
1 is equal to voted
Now what im trying to do is count all the people that is yellow and have not voted already.
I have this code
for (int i = 0; i < dataGridView1.Rows.Count; ++i)
{
if (Convert.ToInt16(dataGridView1[1, i].Value) == 1 && Convert.ToInt16(dataGridView1[4, i].Value) == 0)
{
sum += 1;
}
label1.Text = sum.ToString();
}
but it keeps showing me 0 as total not voted. The datagridview starts with column 0 which is name.
Any ideas on how to help me?..kind of a newbie
Aucun commentaire:
Enregistrer un commentaire