gpt4 book ai didi

c# - 使用 DataRow.BeginEdit() 和 DataRow.EndEdit() 进行单一更改

转载 作者:太空宇宙 更新时间:2023-11-03 23:03:51 25 4
gpt4 key购买 nike

我有很多如下形式的代码:

// assume that MyDataRow is a datarow from a typed dataset and has a property called SomeInt 
MyDataRow row;

row.BeginEdit();
row.SomeInt = 42;
row.EndEdit();

documentation DataRow.BeginEdit 声明如下:

Use the BeginEdit method to put a DataRow into edit mode. In this mode, events are temporarily suspended, letting the user make changes to more than one row without triggering validation rules.

因此,在给定的情况下,当只有一个更改时,根本不需要使用 BeginEdit 和 EndEdit 方法,还是我遗漏了什么? IE。摆脱这些电话是否安全,还是保留它们是一种好的做法?

最佳答案

如果您通过将数据绑定(bind)到控件来工作,那么请使用BeginEdit() 和EndEdit()始终。您的项目中可能有事件或触发器,如果您不使用BeginEdit() 和EndEdit(),您的赋值 可能会更改任何事件或触发器,查找错误将花费大量时间。

关于c# - 使用 DataRow.BeginEdit() 和 DataRow.EndEdit() 进行单一更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42064586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com