コード例 #1
0
        private void EditModelAt(int idx)
        {
            if (idx > Model.Count || idx < 0)
            {
                return;
            }

            Location model = Model[idx].Clone() as Location;

            using (LocationEditForm form = new LocationEditForm {
                Model = model
            })
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    Model[idx] = form.Model;
                    Model.Sort(new LocationComparer());
                    UpdateView();
                }
            }
        }
コード例 #2
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (Model == null)
            {
                return;
            }
            Location newLoc = new Location {
                Id = GeneralHelper.GetNewId(Model)
            };

            using (LocationEditForm form = new LocationEditForm {
                Model = newLoc
            })
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    Model.Add(form.Model);
                    Model.Sort(new LocationComparer());
                    UpdateView();
                }
            }
        }