Question

Clickable Number Images from Starting out with Visual C# 5th Edition page 113 This is the...

Clickable Number Images from Starting out with Visual C# 5th Edition page 113

This is the code I have written:

}

private void pictureBoxOne_Click(object sender, EventArgs e)

{

questionBoxOne.Visible = true;

pictureBoxOne.Visible = false;

showNumber.Text = "";

}

private void questionBoxOne_Click(object sender, EventArgs e)

{

questionBoxOne.Visible = false;

pictureBoxOne.Visible = true;

showNumber.Text = "One";

pictureBoxTwo.Visible = true;

pictureBoxThree.Visible = true;

pictureBoxFour.Visible = true;

pictureBoxFive.Visible = true;

}

private void pictureBoxTwo_Click(object sender, EventArgs e)

{

questionBoxTwo.Visible = true;

pictureBoxTwo.Visible = false;

showNumber.Text = "";

}

private void questionBoxTwo_Click(object sender, EventArgs e)

{

questionBoxTwo.Visible = false;

pictureBoxTwo.Visible = true;

showNumber.Text = "Two";

pictureBoxOne.Visible = true;

pictureBoxThree.Visible = true;

pictureBoxFour.Visible = true;

pictureBoxFive.Visible = true;

}

private void pictureBoxThree_Click(object sender, EventArgs e)

{

questionBoxThree.Visible = true;

pictureBoxThree.Visible = false;

showNumber.Text = "";

}

private void questionBoxThree_Click(object sender, EventArgs e)

{

questionBoxThree.Visible = false;

pictureBoxThree.Visible = true;

showNumber.Text = "Three";

pictureBoxOne.Visible = true;

pictureBoxTwo.Visible = true;

pictureBoxFour.Visible = true;

pictureBoxFive.Visible = true;

}

private void pictureBoxFour_Click(object sender, EventArgs e)

{

questionBoxFour.Visible = true;

pictureBoxFour.Visible = false;

showNumber.Text = "";

}

private void questionBoxFour_Click(object sender, EventArgs e)

{

questionBoxFour.Visible = false;

pictureBoxFour.Visible = true;

showNumber.Text = "Four";

pictureBoxOne.Visible = true;

pictureBoxTwo.Visible = true;

pictureBoxThree.Visible = true;

pictureBoxFive.Visible = true;

}

private void pictureBoxFive_Click(object sender, EventArgs e)

{

questionBoxFive.Visible = true;

pictureBoxFive.Visible = false;

showNumber.Text = "";

}

private void showNumber_Click(object sender, EventArgs e)

{

showNumber.Text = "";

}

private void exitButton_Click(object sender, EventArgs e)

{

this.Close();

}

private void questionBoxFive_Click(object sender, EventArgs e)

{

questionBoxFive.Visible = false;

pictureBoxFive.Visible = true;

showNumber.Text = "Five";

pictureBoxOne.Visible = true;

pictureBoxTwo.Visible = true;

pictureBoxThree.Visible = true;

pictureBoxFour.Visible = true;

}

private void resetButton_Click(object sender, EventArgs e)

{

Application.Restart();

}

}

}

This is what I want to accomplish:

Only ONE PictureBox control can display a number and number name at any given time. Therefore, if the user clicks on a different PictureBox control displaying a question mark, the other number PictureBox control(s) should be changed to the question mark PictureBox control and the Label control displaying the number name should display the newly selected number name.

Please assist me on how to accomplish this.

Homework Answers

Answer #1

Note: Done accordingly. Please comment for any problem. Please Uprate. Thanks.

Download code, extract it using 7zip,winrar etc. open .sln file with visual studio. Run the program.

Download Code:

https://drive.google.com/open?id=1tGU5McbApNeSfK0s9gzjiO6PO1Hjk3ld

Code:

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 PictureBox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void pictureBoxOne_Click(object sender, EventArgs e)
{
reset();
pictureBoxOne.Image = Properties.Resources._1;
pictureBoxOne.Refresh();
showNumber.Text = "One";
}

private void reset()
{
pictureBoxOne.Image = Properties.Resources.question;
pictureBoxOne.Refresh();
pictureBoxTwo.Image = Properties.Resources.question;
pictureBoxTwo.Refresh();
pictureBoxThree.Image = Properties.Resources.question;
pictureBoxThree.Refresh();
pictureBoxFour.Image = Properties.Resources.question;
pictureBoxFour.Refresh();
pictureBoxFive.Image = Properties.Resources.question;
pictureBoxFive.Refresh();
showNumber.Text = "";
}

private void pictureBoxTwo_Click(object sender, EventArgs e)
{
reset();
pictureBoxTwo.Image = Properties.Resources._2;
pictureBoxTwo.Refresh();
showNumber.Text = "Two";
}

private void pictureBoxThree_Click(object sender, EventArgs e)
{
reset();
pictureBoxThree.Image = Properties.Resources._3;
pictureBoxThree.Refresh();
showNumber.Text = "Three";
}

private void pictureBoxFour_Click(object sender, EventArgs e)
{
reset();
pictureBoxFour.Image = Properties.Resources._4;
pictureBoxFour.Refresh();
showNumber.Text = "Four";
}

private void pictureBoxFive_Click(object sender, EventArgs e)
{
reset();
pictureBoxFive.Image = Properties.Resources._5;
pictureBoxFive.Refresh();
showNumber.Text = "Five";
}
}
}

Sample Output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
I am trying to make a program in C# and was wondering how it could be...
I am trying to make a program in C# and was wondering how it could be done based on the given instructions. Here is the code that i have so far... namespace Conversions { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if...
In C++ Employee Class Write a class named Employee (see definition below), create an array of...
In C++ Employee Class Write a class named Employee (see definition below), create an array of Employee objects, and process the array using three functions. In main create an array of 100 Employee objects using the default constructor. The program will repeatedly execute four menu items selected by the user, in main: 1) in a function, store in the array of Employee objects the user-entered data shown below (but program to allow an unknown number of objects to be stored,...
What is the output of the following Java program? public class Food {     static int...
What is the output of the following Java program? public class Food {     static int count;     private String flavor = "sweet";     Food() { count++; }     void setFlavor(String s) { s = flavor; }     String getFlavor() { return flavor; }     static public void main(String[] args) {         Food pepper = new Food();         pepper.setFlavor("spicy");         System.out.println(pepper.getFlavor());     } } Select one: a. sweet b. 1 c. The program does not compile. d. 2 e. spicy...
Task 1: You will modify the add method in the LinkedBag class.Add a second parameter to...
Task 1: You will modify the add method in the LinkedBag class.Add a second parameter to the method header that will be a boolean variable: public boolean add(T newEntry, boolean sorted) The modification to the add method will makeit possible toadd new entriesto the beginning of the list, as it does now, but also to add new entries in sorted order. The sorted parameter if set to false will result in the existing functionality being executed (it will add the...
Subject- ( App Development for Web) ( language C#, software -visual studio) Exact question is-Firstly the...
Subject- ( App Development for Web) ( language C#, software -visual studio) Exact question is-Firstly the console calculator is created which perform multiply,divide,sub and add, operation and it accept all type of data (divide by 0 case as well ).Now the main motive is to create the library project from the console calculator project .Than we have to create a unit test project which test the functionality of added library.Make test like Test 1. multiply two positive number,Test 2. Add...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML As a review, Here are some links to some explanations of UML diagrams if you need them. • https://courses.cs.washington.edu/courses/cse403/11sp/lectures/lecture08-uml1.pdf (Links to an external site.) • http://creately.com/blog/diagrams/class-diagram-relationships/ (Links to an external site.) • http://www.cs.bsu.edu/homepages/pvg/misc/uml/ (Links to an external site.) However you ended up creating the UML from HW4, your class diagram probably had some or all of these features: • Class variables: names, types, and...
this is the book name. Data Structures and Abstractions with Java 1) Description: The sample programs...
this is the book name. Data Structures and Abstractions with Java 1) Description: The sample programs in Chapter 1 of your textbook are not complete. They are used for illustration purpose only. The implementation of Listing 1-1 on page 39 is explained in Chapter 2. And, in order to see the result of using it, we will need the following set of files: i. BagInteface.java – the specification only. ii. ArrayBag.java – the implementation of BagInerface.java. iii. ArrayBagDemo.java – a...
Compile and execute the application. You will discover that is has a bug in it -...
Compile and execute the application. You will discover that is has a bug in it - the filled checkbox has no effect - filled shapes are not drawn. Your first task is to debug the starter application so that it correctly draws filled shapes. The bug can be corrected with three characters at one location in the code. Java 2D introduces many new capabilities for creating unique and impressive graphics. We’ll add a small subset of these features to the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the...
Can someone please edit my code so that it satisfies the assignments' requirements? I pasted the codes below. Requirement: Goals for This Project:  Using class to model Abstract Data Type  OOP-Data Encapsulation You are asked to write an app to keep track of a relatively small music library. The app should load song information from a data file once the app is started. It should allow user to view, add, remove, and search for songs. The app should...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code...
Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code to initialize the CustomerAccountsDB database table and add a set of customer accounts is provided. Finish the code in these 3 methods in CustomerAccountDB.java to update or query the database: -purchase(double amountOfPurchase) -payment(double amountOfPayment) -getCustomerName() Hint: For getCustomerName(), look at the getAccountBalance() method to see an example of querying data from the database. For the purchase() and payment() methods, look at the addCustomerAccount() method...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT