Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i having a little advance with Command Button

lets say i having a form with

label1
label2
label3

And one command button of course

before click the command button

label1.Visible = true;
label2.Visible = false;
label3.Visible = false;

if i click the command button

label1.Visible = false;
label2.Visible = true;
label3.Visible = false;

and then i click again

label1.Visible = false;
label2.Visible = false;
label3.Visible = true;

and repeated again, then back to first before i click the command button

i didnt have any reference on this, so i just make a duplicated command button with same position in form, and i use the visible to get the another command button to be clicked

but it looks not cool,

is there any way better than i make?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
205 views
Welcome To Ask or Share your Answers For Others

1 Answer

you can make one button, and count the number of clicks the user has done, depending on the mod operation you can invoke any of the three method you provide, something like this:

   int count = 1; //count clicks    
   private void ButtonClick(object sender, EventArgs e)
        {
           if(count%2 == 0)
           {
              label1.Visible = false;
              label2.Visible = true;
              label3.Visible = false;
           }
           else if(count%3 == 0){
              label1.Visible = false;
              label2.Visible = false;
              label3.Visible = true;
           }
           else{
             label1.Visible = true;
             label2.Visible = false;
             label3.Visible = false;
           }
        count++;
        }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...