Zebra0.com

csharp boolean


Text of video
Review the video on centering first.
private void Form1_Load(object sender, EventArgs e)
{
   //Position the label so that it is just off the right edge, you can't see it
   lblSale.Location = new Point(this.Width, lblSale.Location.Y);
   timer1.Enabled = true;
   timer1.Interval = 20;
}

private void timer1_Tick(object sender, EventArgs e)
{
   //Scroll the lable 1 X position to the left
   int yPos = lblSale.Location.Y;  //no change
   int xPos = lblSale.Location.X - 1; //move to left
   // If the label has moved off the form on the left 
   // restart on the right 
   if (xPos < 0 - lblSale.Width) //moved off on left
   {
       xPos = this.Width; //off the form on the right
   }// Set location to new values
   lblSale.Location = new Point(xPos, yPos); //moves to left
}

End of lesson, Next lesson: