【发布时间】:2020-04-09 01:29:46
【问题描述】:
我有一个 Window1,其中包含一个数据网格,当 Window1 加载时,该数据网格填充了 MYSQL 数据库,但是要进行更新,有这个 Window2 包含文本框,以便将新信息保存在 MYSQL 数据库中。 我可以在打开和关闭 Window2 后更新信息,如下所示:
Window2.ShowDialog();
//refreshing datagrid
Mouse.OverrideCursor = System.Windows.Input.Cursors.AppStarting;
dtCustomers = AdminDB.Get_Table("SELECT id, name FROM engcustomers", db.MySqlCon);
dataGrid.DataContext = dtCustomers;
MessageBox.Show("The information has been updated correctly");
Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
这很好用,问题出现在 Window2 我按下“取消”按钮时,因为我不想更新任何内容,但由于我的代码,无论如何都会执行查询。 这就是为什么我需要您的支持/帮助来从 Window2 更新 Window1 中的数据网格。
你能帮帮我吗?
提前谢谢你们!
【问题讨论】: