private void DoEditItem(Merchant merchant) { if (merchant == null) { return; } using (var dlg = new EditMerchantDialog()) { dlg.Text = "Edit Merchant"; dlg.MerchantName = merchant.Name; dlg.Selection = merchant.Values; if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string name = dlg.MerchantName; if (name != merchant.Name) { list.Remove(merchant); merchant.Name = name; list.Insert(merchant, CompareMerchants); lstMerchants.SelectedItem = merchant; } merchant.Values = dlg.Selection.ToArray(); } } }
private void editorButtons_AddClick(object sender, EventArgs e) { using (var dlg = new EditMerchantDialog()) { dlg.Text = "Add Merchant"; if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { list.Insert(new Merchant { ID = ID.Gen(), Name = dlg.MerchantName, Values = dlg.Selection.ToArray(), }, CompareMerchants); } } }
private void cboMerchant_AddNewValue(object sender, DevExpress.XtraEditors.Controls.AddNewValueEventArgs e) { using (var dlg = new EditMerchantDialog()) { dlg.Text = "Add Merchant"; dlg.MerchantName = cboMerchantView.FindFilterText; if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { var merchant = new Merchant { ID = ID.Gen(), Name = dlg.MerchantName, Values = dlg.Selection.ToArray(), }; merchantSource.Add(merchant); e.NewValue = merchant.ID; } else { e.Cancel = true; } } }