Hello:
I would like the correct C# syntax to populate datagridview column comboboxes. Each column will look at a query (Entity Framework 6), converted to a list, and would make those values the correct ones to choose from. There should also be a blank for a default.
Currently, I have this code.
- DataTable dt_Employee = timeDataSet.Tables["Employee"];
- DataTable dt_TimeData = timeDataSet.Tables["TimeData"];
- DataTable dt_Activity = timeDataSet.Tables["Activity"];
- DataTable dt_Jobs = timeDataSet.Tables["Jobs"];
- var qryProjectNumbers = from a in dt_Jobs.AsEnumerable()
- orderby a.Field
("ProjectNumber") - where (a.Field
("ProjectNumber") != null) - select a.Field
("ProjectNumber"); - var lstProjectNumbers = qryProjectNumbers.Distinct().ToList();
- var qryActivity = from a in dt_Jobs.AsEnumerable()
- orderby a.Field
("Activity") - where (a.Field
("Activity") != null) - select a.Field
("Activity"); - var lstActivity = qryActivity.Distinct().ToList();
- // How do I add combobox columns?
- dgvTime.Controls.OfType
().ElementAt(iProjectNo).DataSource = lstProjectNumbers; - dgvTime.Controls.OfType
().ElementAt(iActivity).DataSource = lstActivity; - this.timeDataTableAdapter1.Fill(this.timeDataSet.TimeData);
Thank you.

Vinod Kakade15 reputationPosted Jun 14, 2018, 2:57 AM EDT
Stephen Anderson23 reputationPosted Jun 14, 2018, 7:51 AM EDT
Stephen Anderson23 reputationPosted Jun 18, 2018, 6:55 AM EDT
Stephen Anderson23 reputationPosted Jun 18, 2018, 10:57 AM EDT