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

About this user

Dave http://pedotnet.blogspot.com

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

Toggle Text on Button (Using thread timers)

// Works on a seperate thread and changes the color of a button if a significant event happens

   1  
   2  void HotShotTick(object obj)
   3  {
   4  if (this.InvokeRequired) { this.Invoke((MethodInvoker)delegate {
   5  this.FillHotshots();
   6  if (this.dsSignificant.HotshotBets.Rows.Count > 0)
   7  {
   8  this.btnHotShotBets.BackColor = Color.Red;
   9  }
  10  else
  11  {
  12  this.btnHotShotBets.BackColor = Color.Green;
  13  }
  14  });
  15  }
  16  

Toggle Text on Button (Single thread application)

// description of your code here

   1  
   2   public partial class Form1 : Form
   3      {
   4          int iBtn = 0;
   5          public Form1()
   6          {
   7              InitializeComponent();
   8          }
   9  
  10          private void button1_Click(object sender, EventArgs e)
  11          {
  12              ++iBtn;
  13  
  14              if (iBtn == 3)
  15              {
  16                  iBtn = 0;
  17              }
  18  
  19              switch (iBtn)
  20              {
  21                  case 0: button1.Text = "default";
  22                      break;
  23                  case 1: button1.Text = "Love";
  24                      break;
  25                  case 2: button1.Text = "Hate";
  26                      break;
  27              }
  28          }
  29  
  30          private void Form1_Load(object sender, EventArgs e)
  31          {
  32              button1.Text = "default";
  33          }
  34      }
« Newer Snippets
Older Snippets »
Showing 1-2 of 2 total  RSS