C# AutoSize DatagridView Populated By Linq Query -


I have a datagrid view control that is populated by a linq query:

  Public static IQueryable SearchByDepartmentNameInfo (string deptName) {ExamineDataContext DC = new testDATEText (); Var queryResult = dcGetTable in q with & lt; Question & gt; () Where q.Topic.Module.Department.DepartmentName.Equals (deptName) are included in d.Colutions is equal to q.QuestionID in q.QuestionID qs // Note group selection new {module = q.Topic.ModuleTitle , Topic = q.TopicName, question = q.QuestionText, question type = q.QuestionType;}; Return query result; } DataGrid View1.DataSource = Repository. SearchByDepartmentNameInfo ("computer science");  

I want the datagrid view to automatically resize the column based on the returned data from the query.

The help is greatly appreciated.

>

this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;


Comments