示例#1
0
        private void button2_Click(object sender, EventArgs e)
        {
            var dog = new DogForm(new Dog {
                DateOfBirth = DateTime.Now
            });

            if (dog.ShowDialog(this) == DialogResult.OK)
            {
                listBox1.Items.Add(dog.Dog);
            }
        }
示例#2
0
        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int index = this.listBox1.IndexFromPoint(e.Location);

            if (index != System.Windows.Forms.ListBox.NoMatches)
            {
                var item = (Dog)listBox1.Items[index];
                var ff   = new DogForm(item);
                if (ff.ShowDialog(this) == DialogResult.OK)
                {
                    listBox1.Items.Remove(item);
                    listBox1.Items.Insert(index, item);
                }
            }
        }