// Method to seach by Last Name

        private void LastNameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // ceate a new dialog for displaying and configure it
            SearchFirstNameDialog snfd = new SearchFirstNameDialog();

            snfd.SearchbyLName = true;

            // show the dialog and and wait for the Ok
            DialogResult result = snfd.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }

            // loop through the ite contain in the inventory and only display the item that match with search paramer
            displayContactListbox.ClearSelected();
            for (int i = 0; i < PeopleInventory.Count; i++)
            {
                if (PeopleInventory[i].LastName.ToLower().Contains(snfd.searchParameter.ToLower()))
                {
                    displayContactListbox.SetSelected(i, true);
                }
            }
            MessageBox.Show($"{displayContactListbox.SelectedItems.Count.ToString()} items found");
        }
        // Method to seach by first and lastname
        private void FirstAndLastNameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string fname;
            string lname;

            // ceate a new dialog for displaying and configure it
            SearchFirstNameDialog snfd = new SearchFirstNameDialog();

            snfd.SearchbyFLName = true;

            // show the dialog and and wait for the Ok
            DialogResult result = snfd.ShowDialog();

            if (result != DialogResult.OK)
            {
                return;
            }



            try
            {
                //SplitString(snfd.searchParameter);
                char[]   delimeters = { ' ', ',' };
                string[] tokens     = snfd.searchParameter.Split(delimeters, StringSplitOptions.RemoveEmptyEntries);
                fname = tokens[0];
                lname = tokens[1];
                // loop through the ite contain in the inventory and only display the item that match with search paramer
                displayContactListbox.ClearSelected();
                for (int i = 0; i < PeopleInventory.Count; i++)
                {
                    if (PeopleInventory[i].FirstName.ToLower().Contains(fname.ToLower()) &&
                        PeopleInventory[i].LastName.ToLower().Contains(lname.ToLower()))
                    {
                        displayContactListbox.SetSelected(i, true);
                    }
                }
                MessageBox.Show($"{displayContactListbox.SelectedItems.Count.ToString()} items found");
            }
            catch (Exception excp)
            {
                MessageBox.Show($"Leave space between first and last name", "Format Error");
                return;
            }
        }