what i want is when the user enters the info in text boxes for that info to be stored into an array then the last name, first name to be shown up in the listtextbox but all i get now is nothing. Any help would be appreciated. lstDisplay.Text is my list text boxCode:int itemCount; public struct addressBook { public string lastName; public string firstName; public string street; public string city; public string state; public int zip; } addressBook[] book = new addressBook[20]; public MainForm() { InitializeComponent(); } private void btnAdd_Click(object sender, EventArgs e) { string wholeName = ""; try { // if (lstDisplay.SelectedIndex != 0) // { book[itemCount].lastName = txtLast.Text; book[itemCount].firstName = txtFirst.Text; book[itemCount].street = txtStreet.Text; book[itemCount].city = txtCity.Text; book[itemCount].state = txtState.Text; book[itemCount].zip = int.Parse(mTxtZip.Text); itemCount++; clear(); // lbltest.Text = book[itemCount].ToString(); //} // else // { // MessageBox.Show("ERROR!!\n" + "Check your input."); // } } catch (FormatException) { MessageBox.Show("ERROR!!\n" + "Check your input."); } for (int i = 0; i < book.Length; i++) { wholeName = book[i] + "\n" + wholeName ; } lstDisplay.Text = wholeName; //book[itemCount].lastName + " , " + book[itemCount].firstName; lbltest.Text = wholeName; }
Bookmarks