C
Ciro
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.AutoGenerateColumns=false;
dgwPersons.Columns.Add("Name","Name");
dgwPersons.Columns[0].DataPropertyName="Name";
dgwPersons.Columns.Add("Surname","Surname");
dgwPersons.Columns[1].DataPropertyName="Surname";
BindingSource personsBindingSource=new BindingSource();
personsBindingSource.DataSource=Persons; //Persons is the collection
dgwPersons.DataSource=personBindingSource;
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.AutoGenerateColumns=false;
dgwPersons.Columns.Add("Name","Name");
dgwPersons.Columns[0].DataPropertyName="Name";
dgwPersons.Columns.Add("Surname","Surname");
dgwPersons.Columns[1].DataPropertyName="Surname";
BindingSource personsBindingSource=new BindingSource();
personsBindingSource.DataSource=Persons; //Persons is the collection
dgwPersons.DataSource=personBindingSource;
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.