private void MainGrid_SelectedItemChanged(object sender, DevExpress.Xpf.Grid.SelectedItemChangedEventArgs e) { if (e.OldItem == null) { return; } model = e.NewItem as TB_VietnamCompany; EditGrid.DataContext = model; }
void DelModel() { if (MainGrid.SelectedItem == null) { MessageBox.Show("请选择一行"); return; } if (MessageBox.Show("是否确认删除?", "删除确认", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { model = MainGrid.SelectedItem as TB_VietnamCompany; model.FStatus = false; visaORM.ObjectStateManager.ChangeObjectState(model, System.Data.EntityState.Modified); visaORM.SaveChanges(); vietnamCollection.Remove(model); } }
void NewModel() { model = new TB_VietnamCompany(); EditGrid.DataContext = model; }