Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

Changes made in one form are not shown on another form

I have a form called employee that shows all employees in a datagridview.  When you double click on an employee, a new window opens and displays the data for that employee.  When the user changes data and saves it, the changed data is not being shown in the employee form.  IF I exit the employee form and come back in, the changed data shows.  How can I get the changes made on the one form to reflect back in the main form?
Employee.vb
Private Sub Employee_Load(...) Handles ...
Try
  My.Forms.Startup.EmployeesTableAdapter.Fill(My.Forms.Startup.PfmsDataSet.Employees)
Catch ex as Exception
  MsgBox(ex.Message)
End Try
End sub
 
Public Sub ReloadEmployees()
Try
  My.Forms.Startup.EmployeesTableAdapter.ClearBeforeFill = True
  My.Forms.Startup.EmployeesTableAdapter.Fill(My.Forms.Startup.pfmsDataSet.Employees)
  Em.EmployeeDataGridVIew.Refresh()
Catch ex As Exception
  MsgBox(ex.Message)
End Try
End Sub
 
ModifyEmployee.vb
 
Private Sub SubmitButton_Click(...) Handles ...
If SaveEmployeeData() Then
  ' Data is saved
  My.Forms.Employee.ReloadEmployees()
  Me.Close()
End If
End Sub

Open in new window

0
dyarosh
Asked:
dyarosh
  • 2
1 Solution
 
AvelanCommented:
I think you have to rebind the dataset to the gridview.

-Avelan
0
 
dyaroshAuthor Commented:
How do I do that programmatically?
0
 
dyaroshAuthor Commented:
Turns out I was filling the wrong table.  Your suggestion for rebinding the dataset to the gridview showed me I was using the wrong table adapter.  Everything works fine now.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now