Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# language Please:: Create a Console Application project. ( important one to answer) Within the namespace and outside of the wrapper class for Main create

C# language Please::

Create a Console Application project. ( important one to answer)

Within the namespace and outside of the wrapper class for Main create a class named assignment8 that inherits from System.Windows.Forms.

Instantiate a button control from System.Windows.Forms and name it btnClickMe.

Instantiate a button control from System.Windows.Forms and name it btnExit.

Set the form title bar to display "Assignment 8".

Set the form size properties to 300, 150.

Set the btnClickMe text to "Press Me" and the btnExit text to "Exit".

Add the two button controls to the form.

Set the btnClickMe location to coordinates 15, 20 and the btnExit location to coordinates 15, 60.

Register a new EventHandler for the Click event of the btnClickMe button and a new EventHandler for the Click event of the btnExit button.

Write the btnClickMe_Click event method and code the method to show a messagebox with "The Button Has Been Clicked" as text and "Click Me" in the MessageBox title bar when the Click event is fired.

Write the btnExit_Click event method and code the method to exit the application when the Click event is fired.

In Main run/instantiate an assignment8 form.

Internal documentation.

Submit Assignment8a .cs file by including the .cs file in the zipped file with the Assignment8b folder(s) noted below.

Notes: The requirements for this assignment are covered in the supporting material for this week. The assignment will require you to stretch your knowledge into some of the later chapters of the text and possibly some outside sources.

The form you are creating is run from a console application. You are creating a class for the form that inherits from System.Windows.Forms and because of this you can access and set all of the properties that the form has. The button objects also inherit from System.Windows.Forms and the button properties are all available to set/change. The two buttons also carry all of the button object methods such as Click, MouseOver etc. You need to write and implement the Click event method for each button.

All Windows Forms programs with their form and control objects act/change based on events. An event is an action on an object such as clicking a button. When a button is clicked, an event is registered by way of what is called a delegate (covered in a later chapter) and the event occurrence is passed to an event handler which implements an event method. Each button control has a _Click event method and since you are writing the code for the buttons you will write the event handlers for each button Click event. A click control event header has the general form: protected void _Click(Object sender, EventArgs e) where you would substitute the button name for . The event method takes an two arguments; a sender object and an EventArgs object that are automatically passed by the system. You don't have to pass any objects to the event method; the system does that for you. You just have to write the method header in the correct/expected format and then write the implementing code. The other thing you have to accomplish to make this work is to register or attach each event handler to the named button.click event. This registering process fulfills the delegate requirements for each event. Don't worry right now about the delegate; assume that it is automatically in place. All you have to do is write code to register/attach each event handler to its corresponding button click.

I would write all of the code to implement requirements 1-8 and 12 without the event handlers first and once that works then add the event handling code. When you add the button controls to the form you can use one of two formats. You can do a Controls.Add() for each button or you can add both buttons at once using Controls.AddRange() as shown in the text.

Don't forget to add System.Drawing and System.Windows.Forms as references to your console project.

If you have any questions be sure to ask as early as possible (hint: start the project early in the week).

Here is a video of how Assignment8a and Assignment8b should look and work: assignment8.swf

[Assignment8b.cs] Create a Windows Forms Application project.

Recreate an exact copy of the console application project you just created. Create this application as a Windows Forms application using the Visual Studio IDE to drag and drop the controls onto the form.

Use the same property settings for the form and buttons as you did in the console application.

Bear in mind that you will have to write much less code for this project since the IDE does most of this for you.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions

Question

=+3-49. Rework Problem 3-48 for an elevation of 5000 ft (1500 m).

Answered: 1 week ago

Question

1. What are the peculiarities of viruses ?

Answered: 1 week ago

Question

Describe the menstrual cycle in a woman.

Answered: 1 week ago