Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
217 views
in Technique[技术] by (71.8m points)

How To Make A Child Execute Command Button in C#

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

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

1 Reply

0 votes
by (71.8m points)

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++;
        }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...