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.
Stephen AndersonPosted Jun 18, 2018, 2:57 PM
Stephen AndersonPosted Jun 18, 2018, 10:55 AM
Stephen AndersonPosted Jun 14, 2018, 11:51 AM
Vinod KakadePosted Jun 14, 2018, 6:57 AM