Exemplo n.º 1
0
        private void bulletsListBox_DoubleClick(object sender, EventArgs e)
        {
            if (bulletsListBox.SelectedIndex >= 0)
            {
                using (ElectoralCycleEditBullet dialog = new ElectoralCycleEditBullet())
                {
                    dialog.BulletText = ((PhaseBullet)bulletsListBox.SelectedItem).Text;
                    if (dialog.ShowDialog(this.ParentForm) == DialogResult.OK)
                    {
                        // Update the exising bullet:
                        ((PhaseBullet)bulletsListBox.SelectedItem).Text = dialog.BulletText;


                        typeof(ListBox).InvokeMember("RefreshItems", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod, null, bulletsListBox, new object[] { });
                    }
                    else
                    {
                        dialog.BulletText = string.Empty;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            using (ElectoralCycleEditBullet dialog = new ElectoralCycleEditBullet())
            {
                if (dialog.ShowDialog(ParentForm) == DialogResult.OK)
                {
                    // Create a new Bullet:
                    PhaseBullet newBullet = PhaseBulletHelper.GetNew();
                    newBullet.Text      = dialog.BulletText;
                    newBullet.SortOrder = bulletsListBox.Items.Count + 1;
                    //newBullet.IDPhaseBullet = LastId;

                    // insert in the List and the collection:
                    bulletsListBox.Items.Add(newBullet);
                    _bullets.Add(newBullet);
                }
                else
                {
                    dialog.BulletText = string.Empty;
                }
            }
        }