In the assignment, we will redo what we did in Assignment 1 but not as a console application. Instead we will use a form:
You may find this more time-consuming than Assignment 1 (and more fun).
What to Do
Start a project of type Windows Form Application in Visual Studio and name it "Assign2".
Using the Designer, call up the ToolBox and install controls in your form. You will need:
When you try to compile this (as in "Build"), the Form1.Designer.cs file will be created. You may need to double-click on each control in turn.
In the Form1.cs file, you will find you have a namespace called Assign2 containing a partial class Form1. (The other part is in Form1.Designer.cs.) In the namespace, you can copy in the Person class from Assignment 1 and create methods for the various radio button choices.
You should modify your code to use a List Before doing anything else, the list must be loaded with data. In Form1.cs,
you will find you have a number of event handlers. One of them is called
Form1_Load. Whatever we put here will be done when the form first loads, so
this is where you can call a method called something like LoadList to read the file, etc.
Attach all the buttons to the same event handler; its name is something like
RadioButtons_CheckChanged. This is a line of code for each of them, in
Form1.Designer.cs, listed after the properties of each control, such as
One of the properties of a RadioButton is "Checked". Inside
RadioButtons_Checked Changed, you can check the status of each radio button, as in
and call methods accordingly. After that, clear the button with
as we don't want to execute a choice repeatedly.
Notes
You will be able to reuse some of the code from Assignment 1 but not much.
You do not need the InUse variable, as a list maintans a count of its
items (the Count property). You can use a "foreach" construct to
iterate through the list when necessary.
We are using the same input file as in Assignment 1.
You should give your controls meaningful names such as "PrintButton"
and "NameTextBox". Don't bother with trying to change the name "Form1".
The GroupBox does not need a fancy name, as it simply serves as a
container for the Radio Buttons.
You may have a few event handlers in Form1.cs which you can ignore.
One of the radio buttons is for quitting the program. How do you do that?
You need:
When you add an entry or search for a name or an office number or a telephone
number, you will need to use string input values from the TextBoxes. If the
input value is an empty string, print an error message in the ListBox. Do not
add an entry containing empty strings or search for an empty string.
When you execute a search for a name or an office number or a telephone number,
you should afterwards blank out the TextBox. You can do this using:
You will probably need to look up some details on line.
You should test your work. Make sure each option works.
Make sure your program is adequately documented. You should have a block of
comment lines in each code file that list the assignment number and the names
of all members of your group. You also need at least some comments for each
class and each method.
To submit your work, go to the Blackboard site and locate Assignment 2.
Use an FTP program to copy the entire project folder to some other
location and then compress it, creating a ZIP file. Attach the ZIP
file on Blackboard. The TA will copy the ZIP file to some other location,
decompress it and compile it. Your score and the TA's comments will be
on Blackboard. Each person in your group should have the same score.
this.PrintButton.CheckedChanged +=
new System.EventHandler(this.RadioButtons_CheckedChanged);
if (PrintButton.Checked)
PrintButton.Checked = false;
Application.Exit();
NameTextBox.Clear();