且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何检查是否在C#(wpf)的数据网格中进行了任何修改

更新时间:2023-12-01 11:31:34

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



你可以这样做:

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