Quote:
First thing The DataGridView don't support Dictionary collection. The DataGridView class supports the standard Windows Forms data-binding model. This means the data source can be of any type that implements one of the following interfaces:
1. The IList interface, including one-dimensional arrays.
2. The IListSource interface, such as the DataTable and DataSet classes.
3. The IBindingList interface, such as the BindingList<T> class.
4. The IBindingListView interface, such as the BindingSource class.
Quote:
Second thing If an element with the same key already exists in the Dictionary if will through 'ArgumentException '.
var query4 = list1.Select(t => new { t.empId, t.Department.deptId }).ToDictionary(t => t.empId, t => t.deptId).ToList();
dataGridView5.DataSource = query4;
your code will not give exception if you swap the deptId with empId in Dictionary.