I need help with my final project, I think I have the basic structures set up already. I'm a little lost on loops, do I need one to populate the list? and one to go through the list to display the information back in the text boxes? Also how do I go about displaying the information back? I know I have a good bit to go but if I could just get pointed in the right direction hopefully everything will fall into place. It says to use arrays to store the addresses, but I am allowed to use a list which I think is easier. Here is the project:
Write a Windows Application that maintains an address book. This address book should hold up to 20 entries. You must store your data with arrays. Each address entry will have the following:
• Last Name, First Name
• Street Address
• City
• State
• Zip Code
Your program must have the following functionality:
• Display the address book (names only in alphabetical order by last name)
• Display all information about an individual entry (allow the user to select this)
• Add address entry
• Delete address entry
Here is what I have so far:
public partial class frmunit10 : Form
{
public struct addr
{
public string First;
public string Last;
public string Street;
public string City;
public string State;
public int Zip;
}
public frmunit10()
{
InitializeComponent();
}
List<addr> addresses = new List<addr>();
private void btnadd_Click(object sender, EventArgs e)
{
try
{
addr a1 = new addr();
{
a1.First = txtfirst.Text;
a1.Last = txtlast.Text;
a1.Street = txtstreet.Text;
a1.City = txtcity.Text;
a1.State = txtstate.Text;
a1.Zip = int.Parse(txtzip.Text);
}
addresses.Add(a1);
lbone.Items.Add(a1.Last + ", " + a1.First);
addresses.Clear();
}
catch
{
}
}
private void btndelete_Click(object sender, EventArgs e)
{
lbone.Items.Remove(lbone.SelectedItem);
}
private void btnexit_Click(object sender, EventArgs e)
{
this.Close();
}
private void lbone_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}