Click here to Skip to main content
15,891,633 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
i want to increase the value set in label by 1 unit when i click the button below that label. i am working on WPF C#.
Posted
Comments
Herman<T>.Instance 28-Aug-14 9:20am    
please give definition of Unit
kamal narola 28-Aug-14 9:24am    
integer value...it's a number like 1..then on clicking it should show 2..then again on clicking it should show 3

Try this

C#
private static int iCount = 0;

button_click(object sender,EventArgs e)
{
 iCount = iCount + 1;
 lblText.Text = iCount.ToString(); 
}
 
Share this answer
 
Comments
Herman<T>.Instance 28-Aug-14 9:50am    
iCount = iCount + 1; --> iCount++;
Try this
i have set the lblCount to 0 in the begining
C#
private void btnClick_Click(object sender, RoutedEventArgs e)
        {
            string s = lblCount.Content.ToString();
            int i = Convert.ToInt32(s);
            i = i + 1;
            lblCount.Content = i.ToString();
        }
 
Share this answer
 
Comments
kamal narola 29-Aug-14 8:30am    
Thank you!!..it is working perfectly.

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