need help

+1 Αδαμάντιος Άγγελος Κωνσταντινίδης · December 4, 2015
Guyz I want to make a window form application that changing 3 images!!(green,orange,red traffic light) with a simple button click!!1 click for change to orange,another one to go red ,another one green and that all over again!!!Any help? thanks!:ermm:

Post a Reply

Replies

Oldest  Newest  Rating
0 Žiga Benko · January 14, 2016
  private void button1_Click(object sender, EventArgs e)
        {
            if (pictureBox1.ImageLocation == @"C:\Users\OliverQueen\Desktop\red.png")
            {
                pictureBox1.ImageLocation = @"C:\Users\OliverQueen\Desktop\green.png";
            }
            else if(pictureBox1.ImageLocation == @"C:\Users\OliverQueen\Desktop\green.png")
            {
            pictureBox1.ImageLocation = @"C:\Users\OliverQueen\Desktop\orange.jpg";
            }
            else if (pictureBox1.ImageLocation == @"C:\Users\OliverQueen\Desktop\orange.jpg") {
                pictureBox1.ImageLocation = @"C:\Users\OliverQueen\Desktop\red.png";
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            pictureBox1.ImageLocation = @"C:\Users\OliverQueen\Desktop\red.png";
        }

I hope this will help ;)
  • 1

C#

107,074 followers
About

C# is an object-oriented language designed for improving the development of web applications.

Links
Moderators