How to remember botton click several times on the same buton c#
i could just add integer and if this integer equals true or false, and use if operator but my problem is
int counter;
private void button1_Click(object sender, EventArgs e)
{
{
if (counter == 0)
{
label1.Text = "0";
counter++;
}
if (counter == 1)
{
label2.Text = "1";
counter++;
}
if (counter == 2)
{
label3.Text = "2";
counter++;
}
if (counter == 3)
{
label4.Text = "3";
counter++;
}
}
}
i got it how stupid it was that it will work but pls tell me how it could work, i want to click 4 times on botton1 an get on label1 first at second click on label2 2 and so on
c# click
|
show 7 more comments
i could just add integer and if this integer equals true or false, and use if operator but my problem is
int counter;
private void button1_Click(object sender, EventArgs e)
{
{
if (counter == 0)
{
label1.Text = "0";
counter++;
}
if (counter == 1)
{
label2.Text = "1";
counter++;
}
if (counter == 2)
{
label3.Text = "2";
counter++;
}
if (counter == 3)
{
label4.Text = "3";
counter++;
}
}
}
i got it how stupid it was that it will work but pls tell me how it could work, i want to click 4 times on botton1 an get on label1 first at second click on label2 2 and so on
c# click
if (counter % 4 == 0) { label1.Text = "0"; counter++;}
, where % is themodulo
opreator, also thecounter++
, can be outside of all theif
statements
– styx
Nov 15 '18 at 11:33
You don't needif
just this should workslabel1.Text = counter.ToString(); counter++;
– S.Akbari
Nov 15 '18 at 11:34
1
The above two comments are why I voted to close your question as unclear. I interpreted the question as what @S.Akbari's solution is yet there is apparent room for misinterpretation as seen by styx's comment. Please clarify exactly what you mean.
– Script47
Nov 15 '18 at 11:36
1
@Solutions - seems you didnt notice that he wants to write to different labels and not onlylabel1
... so 0 =label1
- 1 =label2
and so on - you guys only write tolabel1
– Rand Random
Nov 15 '18 at 11:40
i want to add some text in label1 when button1 is clicked and if it will be clicked again there should be another text in button1 and so on(there will be different labels and textboxes too) i need if operator cause there will be another rout in my labyrinth too
– flemeth wow
Nov 15 '18 at 11:41
|
show 7 more comments
i could just add integer and if this integer equals true or false, and use if operator but my problem is
int counter;
private void button1_Click(object sender, EventArgs e)
{
{
if (counter == 0)
{
label1.Text = "0";
counter++;
}
if (counter == 1)
{
label2.Text = "1";
counter++;
}
if (counter == 2)
{
label3.Text = "2";
counter++;
}
if (counter == 3)
{
label4.Text = "3";
counter++;
}
}
}
i got it how stupid it was that it will work but pls tell me how it could work, i want to click 4 times on botton1 an get on label1 first at second click on label2 2 and so on
c# click
i could just add integer and if this integer equals true or false, and use if operator but my problem is
int counter;
private void button1_Click(object sender, EventArgs e)
{
{
if (counter == 0)
{
label1.Text = "0";
counter++;
}
if (counter == 1)
{
label2.Text = "1";
counter++;
}
if (counter == 2)
{
label3.Text = "2";
counter++;
}
if (counter == 3)
{
label4.Text = "3";
counter++;
}
}
}
i got it how stupid it was that it will work but pls tell me how it could work, i want to click 4 times on botton1 an get on label1 first at second click on label2 2 and so on
c# click
c# click
asked Nov 15 '18 at 11:30
flemeth wowflemeth wow
33
33
if (counter % 4 == 0) { label1.Text = "0"; counter++;}
, where % is themodulo
opreator, also thecounter++
, can be outside of all theif
statements
– styx
Nov 15 '18 at 11:33
You don't needif
just this should workslabel1.Text = counter.ToString(); counter++;
– S.Akbari
Nov 15 '18 at 11:34
1
The above two comments are why I voted to close your question as unclear. I interpreted the question as what @S.Akbari's solution is yet there is apparent room for misinterpretation as seen by styx's comment. Please clarify exactly what you mean.
– Script47
Nov 15 '18 at 11:36
1
@Solutions - seems you didnt notice that he wants to write to different labels and not onlylabel1
... so 0 =label1
- 1 =label2
and so on - you guys only write tolabel1
– Rand Random
Nov 15 '18 at 11:40
i want to add some text in label1 when button1 is clicked and if it will be clicked again there should be another text in button1 and so on(there will be different labels and textboxes too) i need if operator cause there will be another rout in my labyrinth too
– flemeth wow
Nov 15 '18 at 11:41
|
show 7 more comments
if (counter % 4 == 0) { label1.Text = "0"; counter++;}
, where % is themodulo
opreator, also thecounter++
, can be outside of all theif
statements
– styx
Nov 15 '18 at 11:33
You don't needif
just this should workslabel1.Text = counter.ToString(); counter++;
– S.Akbari
Nov 15 '18 at 11:34
1
The above two comments are why I voted to close your question as unclear. I interpreted the question as what @S.Akbari's solution is yet there is apparent room for misinterpretation as seen by styx's comment. Please clarify exactly what you mean.
– Script47
Nov 15 '18 at 11:36
1
@Solutions - seems you didnt notice that he wants to write to different labels and not onlylabel1
... so 0 =label1
- 1 =label2
and so on - you guys only write tolabel1
– Rand Random
Nov 15 '18 at 11:40
i want to add some text in label1 when button1 is clicked and if it will be clicked again there should be another text in button1 and so on(there will be different labels and textboxes too) i need if operator cause there will be another rout in my labyrinth too
– flemeth wow
Nov 15 '18 at 11:41
if (counter % 4 == 0) { label1.Text = "0"; counter++;}
, where % is the modulo
opreator, also the counter++
, can be outside of all the if
statements– styx
Nov 15 '18 at 11:33
if (counter % 4 == 0) { label1.Text = "0"; counter++;}
, where % is the modulo
opreator, also the counter++
, can be outside of all the if
statements– styx
Nov 15 '18 at 11:33
You don't need
if
just this should works label1.Text = counter.ToString(); counter++;
– S.Akbari
Nov 15 '18 at 11:34
You don't need
if
just this should works label1.Text = counter.ToString(); counter++;
– S.Akbari
Nov 15 '18 at 11:34
1
1
The above two comments are why I voted to close your question as unclear. I interpreted the question as what @S.Akbari's solution is yet there is apparent room for misinterpretation as seen by styx's comment. Please clarify exactly what you mean.
– Script47
Nov 15 '18 at 11:36
The above two comments are why I voted to close your question as unclear. I interpreted the question as what @S.Akbari's solution is yet there is apparent room for misinterpretation as seen by styx's comment. Please clarify exactly what you mean.
– Script47
Nov 15 '18 at 11:36
1
1
@Solutions - seems you didnt notice that he wants to write to different labels and not only
label1
... so 0 = label1
- 1 = label2
and so on - you guys only write to label1
– Rand Random
Nov 15 '18 at 11:40
@Solutions - seems you didnt notice that he wants to write to different labels and not only
label1
... so 0 = label1
- 1 = label2
and so on - you guys only write to label1
– Rand Random
Nov 15 '18 at 11:40
i want to add some text in label1 when button1 is clicked and if it will be clicked again there should be another text in button1 and so on(there will be different labels and textboxes too) i need if operator cause there will be another rout in my labyrinth too
– flemeth wow
Nov 15 '18 at 11:41
i want to add some text in label1 when button1 is clicked and if it will be clicked again there should be another text in button1 and so on(there will be different labels and textboxes too) i need if operator cause there will be another rout in my labyrinth too
– flemeth wow
Nov 15 '18 at 11:41
|
show 7 more comments
1 Answer
1
active
oldest
votes
ok someone else helped me so it just need return in if
if (counter == 0)
{
label1.Text = "0";
counter++;
return;
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53318511%2fhow-to-remember-botton-click-several-times-on-the-same-buton-c-sharp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
ok someone else helped me so it just need return in if
if (counter == 0)
{
label1.Text = "0";
counter++;
return;
}
add a comment |
ok someone else helped me so it just need return in if
if (counter == 0)
{
label1.Text = "0";
counter++;
return;
}
add a comment |
ok someone else helped me so it just need return in if
if (counter == 0)
{
label1.Text = "0";
counter++;
return;
}
ok someone else helped me so it just need return in if
if (counter == 0)
{
label1.Text = "0";
counter++;
return;
}
answered Nov 15 '18 at 12:33
flemeth wowflemeth wow
33
33
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53318511%2fhow-to-remember-botton-click-several-times-on-the-same-buton-c-sharp%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
if (counter % 4 == 0) { label1.Text = "0"; counter++;}
, where % is themodulo
opreator, also thecounter++
, can be outside of all theif
statements– styx
Nov 15 '18 at 11:33
You don't need
if
just this should workslabel1.Text = counter.ToString(); counter++;
– S.Akbari
Nov 15 '18 at 11:34
1
The above two comments are why I voted to close your question as unclear. I interpreted the question as what @S.Akbari's solution is yet there is apparent room for misinterpretation as seen by styx's comment. Please clarify exactly what you mean.
– Script47
Nov 15 '18 at 11:36
1
@Solutions - seems you didnt notice that he wants to write to different labels and not only
label1
... so 0 =label1
- 1 =label2
and so on - you guys only write tolabel1
– Rand Random
Nov 15 '18 at 11:40
i want to add some text in label1 when button1 is clicked and if it will be clicked again there should be another text in button1 and so on(there will be different labels and textboxes too) i need if operator cause there will be another rout in my labyrinth too
– flemeth wow
Nov 15 '18 at 11:41