I'm attempting to make a program in the old Windows Forms
with c#. I have managed to make a PictureBox
and when the program starts with a randomized couple of images from resources
. My problem is that I have 4 buttons I want to change label text on depending on what image that is on the screen , but without success.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Katter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
List<Image> images = new List<Image>();
images.Add(Properties.Resources.Abessinier);
images.Add(Properties.Resources.Bengal);
images.Add(Properties.Resources.American_curl);
images.Add(Properties.Resources.Balines);
images.Add(Properties.Resources.brittisk_korthår);
Random random = new Random();
pictureBox1.Image = images[random.Next(0, images.Count - 1)];
if (pictureBox1.Image == Properties.Resources.Abessinier )
{
button1.Text = "some text";
button2.Text = "some text";
button3.Text = "some text";
button4.Text = "some text";
}
if (pictureBox1.Image == Properties.Resources.Bengal)
{
button1.Text = "some other text";
button2.Text = "some other text";
button3.Text = "some other text";
button4.Text = "some other text";
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}