开发者

C# DataGridView.DataSource difference between using BindingSource and not

开发者 https://www.devze.com 2023-01-30 14:40 出处:网络
I found that I can just set the DataGridView.DataSource directly to the DataTable without using the BindingSource in between, which is what all of the tutorials I\'ve seen so far are using. So what is

I found that I can just set the DataGridView.DataSource directly to the DataTable without using the BindingSource in between, which is what all of the tutorials I've seen so far are using. So what is the difference bet开发者_开发百科ween these two?


Some information here on how the use of a BindingSource is an improvement to the old way of binding directly to a DataTable.

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

In summary:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消