如何检查是否在C#(wpf)的数据网格中进行了任何修改 [英] how to check whether any modification is done in datagrid in C#(wpf)

查看:65
本文介绍了如何检查是否在C#(wpf)的数据网格中进行了任何修改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据网格,其中向网格添加一些订单。最初网格可以包含零个或多个订单。

现在当用户进行一些修改然后点击退出按钮时,用户应显示警告信息。我已经添加了一条警报消息。



所以如何实现逻辑来检查是否在网格中进行了任何修改。



I have a datagrid where am adding some orders to the grid.Initially the grid can contain zero or more orders.
Now when the user does some modifications then on click of exit button, the user should display an alert message. i have already added an alert message.

so how to implement the logic to check whether any modification is done in the grid.

.

推荐答案

如果您正在使用数组(我建议您这样做),要在填充数据网格时保存数据,您只需检查数值即可是一样的。



你可以这样做:

If you are using an Array, (I recomend that you do), to hold the data when you populate the datagrid, you can just simply check if the values are the same.

You can simply do something like this:
if (newDatagridValue != OldDatagridValue)
{
    databaseField = newDatagridValue;
}



(这是虚拟代码,用于显示我的意思,并且不可用)



因此,如果将包含您所呈现信息的数组与新数组进行比较,当您点击退出按钮时,可以看到它是否已更改并重写您的数据源以反映您的更改。 br $>


-Frank


(this is ofcourse pseudocode to show you what I mean, and not usable)

So if the Array holding the information you have presented is compared to a new array, that is made when you hit the "exit" button, you can see if it has changed and rewrite your data-source to reflect your changes.

-Frank


这篇关于如何检查是否在C#(wpf)的数据网格中进行了任何修改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆