我正在使用 WPF 和 Devxpress。我在我的应用程序中进行了两项操作,即从网格中添加和删除行。两者都工作正常。但是,如果我拖放一列,则删除将停止以同时删除多行。这里的代码和图像,请回答我的查询。
private void DeleteButton_Click(object sender, RoutedEventArgs e)
{
if (DXMessageBox.Show("Are You Sure, you Want to Delete?", "Delete Item-Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
try
{
myEntities dbcontext = new myEntities();
Name per = grid.SelectedItem as Name;
dbcontext.Names.Remove(per);
dbcontext.SaveChanges();
Refresh();
}
}
catch (Exception ex)
{
DXMessageBox.Show(ex.Message.ToString());
}}}
下面的代码可以很好地删除单行:
Name per = grid.SelectedItem as Name;
dbcontext.Names.Remove(per);
dbcontext.SaveChanges();