Question: Visual C# Finish the code: private void btnAddContact_Click(object sender, EventArgs e) { string strContact; //Validate data //Assign strContact to Contact name(30 chars) + Contact Phone

Visual C#

Finish the code:

private void btnAddContact_Click(object sender, EventArgs e) { string strContact;

//Validate data //Assign strContact to Contact name(30 chars) + Contact Phone + Phone Source(7 chars)

//Add contact to list box control using the string variable strContact

//clear Add contact data (contact name, contact phone and phone source)

//set focus to contact name

private void btnOpen_Click(object sender, EventArgs e) { //define a StreamReader variable and name it inputFile string strInput;

//try //{

//Use the Show Open dialog to allow the user to select/open a Contact List disk file

//The filename that is selected should be assigned to the field strDiskFileName //Open the disk file using the OpenText method //clear list box of any items it may have //Set up a while loop using the EndOfStream property

//Read disk record into strInput //Add contact to list box control

//Close disk file //} //catch (Exception ex) //{ // MessageBox.Show("Problems with disk file:" + Environment.NewLine + ex.Message, "Disk File", MessageBoxButtons.OK, MessageBoxIcon.Information);

//}

}

private void btnSave_Click(object sender, EventArgs e) { //Declare StreamWriter variable and name it outputFile int intCount, intloop; string strOutput;

//Make sure there is at least one contact to save if (lstContactNumbers.Items.Count=0) { MessageBox.Show("There are no contacts to save.", "Contact List", MessageBoxButtons.OK, MessageBoxIcon.Information); return; }

if (strDiskFileName=="") //If this is blank then a file was not opened, therefore, it is a new file that is to be saved. { sadSave.Title = "Save Contact List"; // Display Save As Dialog using if statement. Uncomment the following code and finish it //if (sadSave.ShowDialog() == DialogResult.OK) //{ // //assign strDiskFileName to the FileName that was entered //} //else //{ // return; //Saving a disk file was cancelled //}

}

//Open the disk file to be written over, not appended using the variable outputFile //Get the number of contacts in the list intCount = lstContactNumbers.Items.Count;

for (intloop = 0; intloop <= intCount - 1; intloop++) { //assign SelectedIndex of ListBox control to intloop //assign strOutput to Text property of ListBox control //write out contact to disk file making sure a newline character is placed at the end of the record.

}

// close disk file

}

private void btnDeleteContact_Click(object sender, EventArgs e) { int intIndex;

//make sure a contact is selected, if a contact is not selected display an appropriate message //using the MessageBox class and exit the method.

//get selected index of the contact that was chosen and assign it to intIndex

//remove contact from list box by calling the RemoveAt method passing in the selected index (intIndex)

//lstContactNumbers.Items.?;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!