Hi all, I've a problem with a datagridview.
The data source of the control is a List<t> where t is type of a class I've created.
The class (Person) has some properties like Name, Surname and so on.
Now my datagridview is bounded to a collection of Person:
dgwPersons=new DataGridView();
dgwPersons.Auto GenerateColumns =false;
dgwPersons.Colu mns.Add("Name", "Name");
dgwPersons.Colu mns[0].DataPropertyNa me="Name";
dgwPersons.Colu mns.Add("Surnam e","Surname" );
dgwPersons.Colu mns[1].DataPropertyNa me="Surname";
BindingSource personsBindingS ource=new BindingSource() ;
personsBindingS ource.DataSourc e=Persons; //Persons is the collection
dgwPersons.Data Source=personBi ndingSource;
Most of properties of the Person class are strings (like Name and Surname), so I had no problem to bound them to the dgw.
I can even edit the fields in the dgw and have the corresponding property in memory changed.
Now the question is that the class Person have a property (job) of the type of Job (another class);
Furthermore I've got another list<t> where t is type of Job.
The collection contains all possible jobs.
I'd like to have a combobox column in my dgw that shows the corrent job of the person and gives the user the chance to choiche between all jobs in the jobs collection.
How can I do that?
Thank you very much guys.
The data source of the control is a List<t> where t is type of a class I've created.
The class (Person) has some properties like Name, Surname and so on.
Now my datagridview is bounded to a collection of Person:
dgwPersons=new DataGridView();
dgwPersons.Auto GenerateColumns =false;
dgwPersons.Colu mns.Add("Name", "Name");
dgwPersons.Colu mns[0].DataPropertyNa me="Name";
dgwPersons.Colu mns.Add("Surnam e","Surname" );
dgwPersons.Colu mns[1].DataPropertyNa me="Surname";
BindingSource personsBindingS ource=new BindingSource() ;
personsBindingS ource.DataSourc e=Persons; //Persons is the collection
dgwPersons.Data Source=personBi ndingSource;
Most of properties of the Person class are strings (like Name and Surname), so I had no problem to bound them to the dgw.
I can even edit the fields in the dgw and have the corresponding property in memory changed.
Now the question is that the class Person have a property (job) of the type of Job (another class);
Furthermore I've got another list<t> where t is type of Job.
The collection contains all possible jobs.
I'd like to have a combobox column in my dgw that shows the corrent job of the person and gives the user the chance to choiche between all jobs in the jobs collection.
How can I do that?
Thank you very much guys.
Comment