Im just starting off trying to learn C# and im trying some things out.
if (i > 1)
label1.Text = "You clicked me " + i++ + " times!";
label1.Text = "You clicked me 1 time!";
if (checkBox1 == checked);
label1.Text = "You clicked me " + i + " times";
I am trying to make it so you click a button, and a box pops up that says hello world. And it tells you how many times you clicked the button. But now Im trying to make it so you can have a box checked and it stops recording how many times you clicked. Thanks!
General Information for all who posts. Please read the forum rules first. In especially please use codetags, because code is no longer formatted if you dont use them. [code]your code here[/code]
Additional please show all the relevant code including method's body, or the whole delegate where this code occures, declarations and all what is needed to understand what you are doing.
Last edited by JonnyPoet; June 15th, 2010 at 02:54 PM.
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ? My latest articles : Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
public partial class Form1 : Form
private int i;
i = 0;
private void button1_Click(object sender, EventArgs e)
if (!checkBox1.Checked) return;
label1.Text = @"You clicked me " + i + @" times!";
Its simple C# coding, and these are some basic things :
1. Any variable that you want to check across functions, or store it during a program's instance execution, can be stored as a member variable.
2. You can also use the Tag value of the button to store how many times they clicked, avoiding a member variable i.
button1.Tag = Int32.Parse(button1.Tag) + 1;