How do I stop auto refresh of datagridview

I am having a problem with my datagridview reloading. I am working in VB.NET 2008 using Access 2007 as my database. I have two forms each with a datagridview one them. One is for current records and one is for old records. On form load the current date is checked to determine if the record is current, see following code

Private Sub frmShowArchieve_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load  

Dim dtHoldDate As Date
dtHoldDate = System.DateTime.Today  
Dim adapter As New SecurityDataSetTableAdapters.se00t01aTableAdapter  
Dim dv As New DataView(adapter.GetOldData)  
With dv  
  .RowFilter = "accto < #" & dtHoldDate & "#"
End With
dgvArchieve.DataSource = dv  

End Sub

My problem is that sometimes the user wants to change the accto date to make the record active again. The user changes the date but as soon as the row loses focus the record disappears from the datagridview. Naturally now the record cannot be updated because it is no longer in the datagridview. I have done extensive searching on the internet and have not been able to find the answer to this issue. Can anyone please tell me how to solve this issue.

Thank you in advance for all your help.



Buhrj1Asked:
Who is Participating?
 
Kelvin McDanielConnect With a Mentor Sr. Developer/ConsultantCommented:
The important thing is that you need to basically disable the auto binding that you get when you use the wizard(s) to setup the DataGridView. This is usually in the auto-generated code in either the Load or Initialize methods (I can't immediately remember which it is with VB). Please note that the physical code may be in the *.designer.cs file that goes with your form.

Typically I would...
1. Abstract the binding functionality to a separate Function.
2. Select/Create at least one appropriate event (button click, focus change, etc). that calls the new Function.
3. You may have to explicitly set the databind to Nothing in the
4. (Optionally) Mimic the Form Load databinding by calling the same function in Form Load.

0
All Courses

From novice to tech pro — start learning today.