Click here to Skip to main content
16,020,669 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,
i have to create a counter in a windows form where i can add todays available students who have attended particular subject class.


Thanks in advance
Posted
Updated 10-Nov-11 22:47pm
v2
Comments
thatraja 11-Nov-11 5:09am    
Elaborate clearly.
Tejas Vaishnav 11-Nov-11 6:08am    
what you want with counter.....
Amol_27101982, India 11-Nov-11 7:37am    
You want to set a limit or you want to count how many students attended ???

Before posting you should at least think that my explanation is sufficient for a third person to understand or not....:(
mkcm2011 14-Nov-11 6:28am    
i have two forms, in my one form i can add new students data...and the data will add in database.Now i have to count number of students by the alert or in another form's label where i could see the total count of particular day and also whenever i run my application the alert should display there that today i have entered .....number of data.

1 solution

This code assumes that you already have a form (Form1) with a button (Button1) and a label (Label1).
C#
public class Form1 : Form
{
    private int _studentsSoFar = 0;

    private void Button1_Click(object sender, EventArgs e)
    {
        _studentsSoFar++;
        Label1.Text = _studentsSoFar.ToString();
    }
}

You can then click the button every time a new student enters the class. When class is over, the amount of students is displayed in Label1.


If you search for something completely different, please rephrase your question using the "Improve question" link.
 
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