Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Toggle Text on Button (Single thread application)

// description of your code here

 public partial class Form1 : Form
    {
        int iBtn = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ++iBtn;

            if (iBtn == 3)
            {
                iBtn = 0;
            }

            switch (iBtn)
            {
                case 0: button1.Text = "default";
                    break;
                case 1: button1.Text = "Love";
                    break;
                case 2: button1.Text = "Hate";
                    break;
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            button1.Text = "default";
        }
    }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS