Click here to Skip to main content
15,891,136 members
Home / Discussions / C#
   

C#

 
AnswerRe: Simulate keypress Pin
Bekjong20-Jan-10 16:07
Bekjong20-Jan-10 16:07 
QuestionProblem with AutoResetEvent Array and WaitHandle.WaitAll() Pin
FJJCENTU20-Jan-10 13:27
FJJCENTU20-Jan-10 13:27 
AnswerRe: Problem with AutoResetEvent Array and WaitHandle.WaitAll() Pin
Bekjong20-Jan-10 15:50
Bekjong20-Jan-10 15:50 
AnswerRe: Problem with AutoResetEvent Array and WaitHandle.WaitAll() Pin
Giorgi Dalakishvili20-Jan-10 19:17
mentorGiorgi Dalakishvili20-Jan-10 19:17 
QuestionManaged and Unmanaged code Pin
3bood.ghzawi20-Jan-10 13:03
3bood.ghzawi20-Jan-10 13:03 
AnswerRe: Managed and Unmanaged code Pin
Bekjong20-Jan-10 15:53
Bekjong20-Jan-10 15:53 
AnswerRe: Managed and Unmanaged code Pin
Abhinav S20-Jan-10 17:33
Abhinav S20-Jan-10 17:33 
QuestionDisplay highlighted data from Listbox in Textboxes Pin
CarlMartin1020-Jan-10 13:02
CarlMartin1020-Jan-10 13:02 
I have an address book program completely done, except for one thing...

When a name is highlighted in the listbox, I need all of their information displayed in the related textboxes. All the contact information is stored in an array. I was playing with the code, and I know how to display just the information in the listbox, which is the first and last name, but I need ALL of the contact info displayed in the textboxes. I have included my code, and a screenshot of what should happen when a name is selected from the listbox.

Screen Shot[]

 public partial class frmAddressBook : Form
    {
        // Create Array to hold contact information
        string[] Contacts = new string[20];
        int i = 0;

        public frmAddressBook()
        {
            InitializeComponent();
        }

        private void AddressBook_Load(object sender, EventArgs e)
        {
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            // Close program
            this.Close();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            // Declare variables
            string lastName = tbxLastName.Text;
            string firstName = tbxFirstName.Text;
            string street = tbxStreet.Text;
            string city = tbxCity.Text;
            string state = tbxState.Text;
            string zip = tbxZip.Text;
            
            // Add contact information for New contact to array
            if (i < 20)
            {

                Contacts[i] = lastName + ", " + firstName;

                i++;

            }

            else
            {

                MessageBox.Show("The Address Book Can Hold a Maximum of 20 Contacts.", "Address Book Full");

            }

            
            //Clear TextBoxes
            tbxFirstName.Text = "";
            tbxLastName.Text = "";
            tbxStreet.Text = "";
            tbxCity.Text = "";
            tbxState.Text = "";
            tbxZip.Text = "";

            // Display list of contact names from array in the listbox
            lstContacts.Items.Clear();

            for (int j = 0; j < 20; j++)
            {

                if (Contacts[j] != null)
                {

                    lstContacts.Items.Add(Contacts[j].ToString().Trim());

                }


            }
        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            // Delete selected contact
            for (int k = 0; k < Contacts.Length; k++)
            {

                try
                {

                    if (Contacts[k].Contains(lstContacts.SelectedItem.ToString()))
                    {

                        Contacts[k] = null;

                    }

                }

                catch
                {

                }



            }

            //Display Refreshed Records in ListBox
            lstContacts.Items.Clear();

            for (int j = 0; j < 10; j++)
            {

                if (Contacts[j] != null)
                {

                    lstContacts.Items.Add(Contacts[j].ToString().Trim());

                }

            }



        }

        private void lstContacts_SelectedIndexChanged(object sender, EventArgs e)
        {
            tbxFirstName.Text = lstContacts.SelectedItem.ToString();

        }
    }
}

AnswerRe: Display highlighted data from Listbox in Textboxes Pin
Luc Pattyn20-Jan-10 13:27
sitebuilderLuc Pattyn20-Jan-10 13:27 
GeneralRe: Display highlighted data from Listbox in Textboxes Pin
CarlMartin1020-Jan-10 13:31
CarlMartin1020-Jan-10 13:31 
GeneralRe: Display highlighted data from Listbox in Textboxes Pin
Luc Pattyn20-Jan-10 13:37
sitebuilderLuc Pattyn20-Jan-10 13:37 
AnswerRe: Display highlighted data from Listbox in Textboxes Pin
Anthony Mushrow20-Jan-10 13:34
professionalAnthony Mushrow20-Jan-10 13:34 
GeneralRe: Display highlighted data from Listbox in Textboxes Pin
CarlMartin1020-Jan-10 13:37
CarlMartin1020-Jan-10 13:37 
Questionuse of information from a previous form Pin
naghoumeh1420-Jan-10 10:22
naghoumeh1420-Jan-10 10:22 
AnswerRe: use of information from a previous form Pin
sanforjackass20-Jan-10 10:42
sanforjackass20-Jan-10 10:42 
GeneralRe: use of information from a previous form Pin
naghoumeh1420-Jan-10 10:54
naghoumeh1420-Jan-10 10:54 
AnswerRe: use of information from a previous form [modified] Pin
sanforjackass20-Jan-10 11:11
sanforjackass20-Jan-10 11:11 
AnswerRe: use of information from a previous form Pin
DaveyM6920-Jan-10 11:05
professionalDaveyM6920-Jan-10 11:05 
QuestionProblem with connection to Socket Pin
gottimukkala20-Jan-10 10:22
gottimukkala20-Jan-10 10:22 
AnswerRe: Problem with connection to Socket Pin
Rozis20-Jan-10 13:02
Rozis20-Jan-10 13:02 
AnswerRe: Problem with connection to Socket Pin
Abhinav S20-Jan-10 17:51
Abhinav S20-Jan-10 17:51 
Questionreading message by pop3 Pin
mohd_mogaly20-Jan-10 10:20
mohd_mogaly20-Jan-10 10:20 
AnswerRe: reading message by pop3 Pin
Rozis20-Jan-10 13:55
Rozis20-Jan-10 13:55 
QuestionXLinq question Pin
Jamie Nordmeyer20-Jan-10 10:18
Jamie Nordmeyer20-Jan-10 10:18 
QuestionConnecting windows application to a web server. [modified] Pin
amnewone20-Jan-10 7:58
amnewone20-Jan-10 7:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.