コード例 #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            /*if (personsListView.SelectedItems.Count == 0)
             *  return;
             * ListViewItem item = personsListView.SelectedItems[0];
             * EditPersonForm editForm = new EditPersonForm();
             * editForm.FirstName = item.Text;
             * editForm.LastName = item.SubItems[1].Text;
             * editForm.Age = Convert.ToInt32(item.SubItems[2].Text);
             * if (editForm.ShowDialog() != DialogResult.OK)
             *  return;
             * item.Text = editForm.FirstName;
             * item.SubItems[1].Text = editForm.LastName;
             * item.SubItems[2].Text = editForm.Age.ToString();*/

            if (personsListView.SelectedIndices.Count == 0)
            {
                return;
            }
            Person         p        = pers[personsListView.SelectedIndices[0]];
            EditPersonForm editForm = new EditPersonForm(p);

            if (editForm.ShowDialog() == DialogResult.OK)
            {
                personsListView.Invalidate();
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Raxel55/CSharp
        private void button1_Click(object sender, EventArgs e)
        {
            Person         p        = new Person();
            EditPersonForm editForm = new EditPersonForm(p);

            if (editForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            pers.Add(p);
            personsListView.VirtualListSize = pers.Count;
            personsListView.Invalidate();
        }
コード例 #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            EditPersonForm editForm = new EditPersonForm();

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

            ListViewItem newItem = personsListView.Items.Add(editForm.FirstName);

            newItem.SubItems.Add(editForm.LastName);
            newItem.SubItems.Add(editForm.Age.ToString());
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: Raxel55/CSharp
        private void button2_Click(object sender, EventArgs e)
        {
            if (personsListView.SelectedIndices.Count == 0)
            {
                return;
            }
            Person         p        = pers[personsListView.SelectedIndices[0]];
            EditPersonForm editForm = new EditPersonForm(p);

            if (editForm.ShowDialog() == DialogResult.OK)
            {
                personsListView.Invalidate();
            }
        }
コード例 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            Person         p        = new Person();
            EditPersonForm editForm = new EditPersonForm(p);

            if (editForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            pers.Add(p);
            personsListView.VirtualListSize = pers.Count;
            personsListView.Invalidate();

            /*ListViewItem newItem = personsListView.Items.Add(editForm.FirstName);
             * newItem.SubItems.Add(editForm.LastName);
             * newItem.SubItems.Add(editForm.Age.ToString());*/
        }
コード例 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            Person p = new Person();
            ///EditPersonForm editForm = new EditPersonForm();
            /// if (editForm.ShowDialog() != DialogResult.OK)
            ///   return;
            EditPersonForm editForm = new EditPersonForm(p);

            if (editForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            //ListViewItem newItem = personsListView.Items.Add(editForm.FirstName);
            // newItem.SubItems.Add(editForm.LastName);
            //  newItem.SubItems.Add(editForm.Age.ToString());
            personsListView.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(personsListView_RetrieveVirtualItem);
            pers.Add(p);
            personsListView.VirtualListSize = pers.Count;
            personsListView.Invalidate();
        }
コード例 #7
0
        private void btnFormat_Click(object sender, EventArgs e)
        {
            if (personsListView.SelectedItems.Count == 0)
            {
                return;
            }

            ListViewItem   item     = personsListView.SelectedItems[0];
            EditPersonForm editForm = new EditPersonForm();

            editForm.FirstName = item.Text;
            editForm.LastName  = item.SubItems[1].Text;
            editForm.Age       = Convert.ToInt32(item.SubItems[2].Text);

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

            item.Text             = editForm.FirstName;
            item.SubItems[1].Text = editForm.LastName;
            item.SubItems[2].Text = editForm.Age.ToString();
        }