Question
Example of project Create a Windows Form Application project using C# language. Create a Form with a text property of Friends Add a Class file
Example of project
Create a Windows Form Application project using C# language.
Create a Form with a text property of Friends
Add a Class file to your project and name it Friend
In the Friend class declare the following:
private string lastName;
private string phoneNumber;
private int month;
private int day;
private string firstName;
Write accessors for each of the declared class variables
Override the class ToString method to return a string in the following format: FirstName + ',' + LastName + ',' + PhoneNumber + ',' + Month + "," + Day
Add a TabControl to the form and size it so that it fills the form
Name the first tabPage Entry.
On the Entry tabPage add four textboxes to take entry for a first name, last name, birth month, and birthday and add a MaskedTextbox to take entry for a phone number formatted as 999-9999.
Add an Enter Friend button which will process the entries made in the textboxes; writing each entry to a file and an Exit button which will exit the application
Name the second tabPage Read
On the Read tabPage, place a Read button which will read the file entries written to the file on the Entry tabPage, an Exit button that will call the Entry page exit button click event and a listbox that will display each entry read from the file when the Read button is clicked
Name the third tabPage Reminder
On the Reminder tabPage, place a textbox that will take an input for the birth month entries that will be displayed, a Reminder button which will read the file entries and display the file entries which have a month value that matches the value entered in the textbox, an Exit button that will call the Entry page exit button click event, and a listbox that will display each matching entry read from the file when the Reminder button is clicked
At the Form level instantiate a Friend object and declare/instantiate a FileStream/StreamReader and a FileStream/StreamWriter object that will open a Friends.txt file with the FileMode set to OpenCreate, FileAccess set to Read, FileShare set to ReadWrite and FileMode set to Append, FileAccess set to Write and FileShare set to ReadWrite respectively
The data entry button will extract the inputs from the textboxes on the Entry tab and will:
Write the data as a comma delimited record to a .txt file using the Friend object ToString method you overrode in the Friend class; also display a messagebox that displays what was written to the file
Include a try-catch block that will display a messagebox with error message for any errors encountered in reading from the textboxes and writing to the file
Clear the write stream buffer
Clear entries in the textboxes
The Read button will accomplish the following:
Read the file and display in the listbox each record splitting out the fields, eliminating the comma delimiters and placing spaces between the fields
Reset the file position pointer to the beginning of the file for the next file read
The Reminder button will accomplish the following:
Take a text entry for the birth month to be searched for
Read the file and display in the listbox each record splitting out the fields, eliminating the comma delimiters and placing spaces between the fields
The birth month and day will be separated by a "/" when the record(s) is displayed
Reset the file position pointer to the beginning of the file for the next file read
Clear the entry in the textbox
When clicking out of tabPage 2 and 3 which contain the listboxes clear the display contents of the listboxes
When the application is terminated close all open FileStream objects
Internal documentation.
Friends Entry Read Reminder Enter First Name: Enter Last Name Enter Phone Number: Enter Birth Month (eg: 100 Enter Birth Day (eg: 24) Enter Friend ExitStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started