gpt4 book ai didi

C# DataGridView.DataSource 使用与不使用 BindingSource 的区别

转载 作者:太空狗 更新时间:2023-10-29 23:34:40 25 4
gpt4 key购买 nike

我发现我可以直接将 DataGridView.DataSource 设置为 DataTable,而无需在两者之间使用 BindingSource,这是我目前看到的所有教程都在使用的方法。那么这两者有什么区别呢?

最佳答案

这里有一些关于使用 BindingSource 如何改进直接绑定(bind)到 DataTable 的旧方法的信息。

http://msdn.microsoft.com/en-us/library/aa480734.aspx

总结:

The BindingSource component simplifies the developer's job by providing currency management, change notification and the ability to easily access the members in a bound list. There are, however, some other lesser-known improvements to the data binding story worth discussing, and in fact, are important additions that complement the functionality offered by the BindingSource component.

The Binding object has several new members in the .NET Framework 2.0 that enable greater control over the binding operation. For example, you can control how data is formatted in a bound control, when the data source is updated, and how null and DBNull values in the data source are handled. These new members are also supported with corresponding Add methods in the ControlBindingsCollection. You can take advantage of these additions by using the Formatting and Advanced Binding dialog box in Visual Studio or through code. In addition, the Binding object has better support for handling exceptions and errors that can occur in the binding process with the addition of the BindingComplete event.

关于C# DataGridView.DataSource 使用与不使用 BindingSource 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4433281/

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