title: How can I force a DataGridView to redraw?
body: <p>I have a DataGridView which uses a BindingSource. This BindingSource points to a read-only property, which is a collection of <code>department</code> objects. When I programmatically add a department to the property, I am having trouble getting the DataGridView to redraw itself + show the new department.</p>
  
  <p>If I set a breakpoint, I verify that the property has the new department; yet the DataGridView does not draw it. If I navigate away from the tab, and then back, the DataGridView displays the new department.</p>
  
  <p>My question is essentially, <strong>how can I programmatically trigger whatever happens when I navigate away from and then back to the DataGridview</strong>, to force it to redraw (or force its BindingSource to update)? I've tried all the following:</p>
  
  <pre><code>AffectedDepartmentsBindingSource.CancelEdit()
  AffectedDepartmentsBindingSource.EndEdit()
  AffectedDepartmentsBindingSource.ResetBindings(False)
  AffectedDepartmentsBindingSource.ResetBindings(True)
  
  AffectedDepartmentsDataGridView.Refresh()
  AffectedDepartmentsDataGridView.Update()
  AffectedDepartmentsDataGridView.Hide()
  AffectedDepartmentsDataGridView.Show()
  </code></pre>
  
  <hr>
  
  <p>Here's the property:</p>
  
  <pre><code>Public ReadOnly Property affectedDepartments As SortableBindingList(Of Department)
      Get
          Dim uniqueDeptIds As New ArrayList
          Dim _affectedDepartments As New SortableBindingList(Of Department)
  
          'Go through products
          For Each p As product In products.Where(Function(pr) pr.isNotACopy)
              If Not uniqueDeptIds.Contains(p.cs_dept_id) Then
                  uniqueDeptIds.Add(p.cs_dept_id)
                  Dim d As New Department With {
                      .schedule = Me,
                      .name = p.department,
                      .cs_dept_id = p.cs_dept_id
                  }
                  _affectedDepartments.Add(d)
              End If
          Next
  
          'Add temp departments
          If _tempDepartment IsNot Nothing Then
              _affectedDepartments.Add(_tempDepartment)
          End If
  
          Return _affectedDepartments
      End Get
  End Property
  </code></pre>