private void button_Edit_Click(object sender, EventArgs e) { Badge selected = SelectedBadge; if (selected != null) { using (BadgeEditForm dialog = new BadgeEditForm()) { dialog.Initialize(selected, _context); if (dialog.ShowDialog(this) == DialogResult.OK) { // Refresh the grid UI to display any updates ((CurrencyManager)dataGridView.BindingContext[_badges]).Refresh(); } } } }
private void button_Add_Click(object sender, EventArgs e) { Badge newBadge = new Badge(); if (BadgeBox != null) { newBadge.BadgeBoxId = BadgeBox.BadgeBoxId; } using (BadgeEditForm dialog = new BadgeEditForm()) { dialog.Initialize(newBadge, _context); if (dialog.ShowDialog(this) == DialogResult.OK) { _badges.Add(newBadge); } } }