コード例 #1
0
        /// <summary>
        /// The ButtonAdd_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonAdd_Click(object sender, EventArgs args)
        {
            // Show the ModifyPhoneNumberForm dialog.
            using (var modifyPhoneNumberForm = new ModifyPhoneNumberForm())
            {
                if (modifyPhoneNumberForm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                var lvItem = new ListViewItem(modifyPhoneNumberForm.NumberInfo.Value);
                lvItem.SubItems.Add(modifyPhoneNumberForm.NumberInfo.Key.ToString());
                lvItem.Tag = modifyPhoneNumberForm.NumberInfo;
                lvPhoneNumbers.Items.Add(lvItem);
                lvPhoneNumbers.Refresh();
            }
        }
コード例 #2
0
        /// <summary>
        /// The ButtonEdit_Click method.
        /// </summary>
        /// <param name="sender">The <paramref name="sender"/> parameter.</param>
        /// <param name="args">The <paramref name="args"/> parameter.</param>
        private void ButtonEdit_Click(object sender, EventArgs args)
        {
            if (lvPhoneNumbers.SelectedItems.Count == 0)
            {
                return;
            }

            var phoneNumber = (KeyValuePair <User.PhoneType, string>)lvPhoneNumbers.SelectedItems[0].Tag;

            // Show the ModifyPhoneNumberForm dialog.
            using (var modifyPhoneNumberForm = new ModifyPhoneNumberForm(phoneNumber))
            {
                if (modifyPhoneNumberForm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                lvPhoneNumbers.SelectedItems[0].SubItems.Clear();
                lvPhoneNumbers.SelectedItems[0].Text = modifyPhoneNumberForm.NumberInfo.Value;
                lvPhoneNumbers.SelectedItems[0].SubItems.Add(modifyPhoneNumberForm.NumberInfo.Key.ToString());
                lvPhoneNumbers.SelectedItems[0].Tag = modifyPhoneNumberForm.NumberInfo;
                lvPhoneNumbers.Refresh();
            }
        }