我有一个由 linq 查询填充的 datagridview 控件:
public static IQueryable SearchByDepartmentNameInfo(string deptName)
{
ExamineDataContext dc = new ExamineDataContext();
var queryResult = from q in dc.GetTable<Question>()
where q.Topic.Module.Department.DepartmentName.Equals(deptName)
join s in dc.Solutions
on q.QuestionID equals s.QuestionID
into qs // note grouping
select new
{
Module = q.Topic.ModuleTitle,
Topic = q.TopicName,
Question = q.QuestionText,
QuestionType = q.QuestionType,
};
return queryResult;
}
dataGridView1.DataSource = Repository.SearchByDepartmentNameInfo("Computer Science");
我希望 datagridview 根据查询返回的数据自动调整列的大小。
非常感谢帮助。