jeudi 16 janvier 2020

Coding problem C# Code -- pictures.Box1.Image = Image.FromFile(@"c:\Pictures\ohms1.jpg");

I have a multiple choice test questions & answers script. It has a random generator of questions and comes with radio button for answering the exam test. I am trying to add some pictures on enter code here:{Form 1,I made to go alone with the questions and possible answers.Most of the questions are straight forward true and false statements. The one problem I have is posting a image in picture box and give it a question with radio buttons for choice of answers or more less the right one. I am stuck on this problem and why it will not work, go to the list of random pictures and show them and the questions

private void Form1_Load(object sender,EventArgs e)
{
    `enter code here`
    Random rnd = new Random();
    int randomNumber = rnd.Next(1,4);
    switch(randomNumber)
    {
        case 1:
            pictureBox1.Image = Image.FromFile(@"c:\Pictures\ohms1.jpg");}
        break;

        case 2:
            pictureBox1.Image = Image.FromFile(@"c:\Pictures\Aideen O'Brien2.jpg");
            break;

        case 3:
            pictureBox1.Image = Image.FromFile(@"c:\Pictures\circuit board picture3.jpg");
            break;

        case 4:
            pictureBox1.Image = Image.FromFile(@"c:\Pictures\circuit board picture4.jpg");
            break;
    }
}



Aucun commentaire:

Enregistrer un commentaire