开发者

Bind object to winForms control element

I have a class named OrganizerNote with fields: public long id; public DateTime CreationDate; public string Title; public string Note;

Als开发者_C百科o I have a class public class XMLOrganizer that has 1 field:

public List<OrganizerNote> Notes=new List<OrganizerNote>();

For example, I have several objects:

OrganizerNote n1 = new OrganizerNote();
OrganizerNote n2 = new OrganizerNote();

with some data in fields. Then I create 1 object

XMLOrganizer xmlOrg = new XMLOrganizer();
xmlOrg.Notes.Add(n1);
xmlOrg.Notes.Add(n2);

So I need to bind each xmlOrg.Notes[0] ... xmlOrg.Notes[i] to Row[i] in datagridView control. And fields values would be in columns.

How could I do so?


make

List<OrganizerNote> Notes=new List<OrganizerNote>();

into

BindingList<OrganizerNote> Notes=new BindingList<OrganizerNote>();

and then create a binding source on the form bind that to the database and then set the binding datasource to the Notes field on the XMLOranizer

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜