开发者

DataBinding to classes

开发者 https://www.devze.com 2023-01-14 08:07 出处:网络
Possible Duplicate: Binding GridView to Objects My C# app contains a Data Object like this: public class Data

Possible Duplicate:

Binding GridView to Objects

My C# app contains a Data Object like this:

public class Data
 {
    public class a {get;set;}
    public class b {get;set;}
 }

public class a
{
  public int first {get;set;}
}
public class b
{
  public int second{get;set;}
 }

I initialize my data when the application starts and my data changes evey time the app is running.

I have a dataGridView and I want to bind to the first property and to second property. The DataGrid contains two columns, that bound to first and to second property.

How can I do this binding? I don't want to change my da开发者_高级运维taSource nor do I want to add data.

NOTE: Remember that my data can change every time the app running.


Use INotifyPropertyChanged Interface and implement NotifyPropertyChanged() method in your source (in your case Class a and b). You should call NotifyPropertyChanged every time the proeprty value changes.

Then you can bind to UI controls that support INOtifyProperyChanged... that's it.

Mark response as answered.

0

精彩评论

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