How do I stop auto refresh of datagridview

Posted on 2011-04-25
Last Modified: 2013-01-22
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.

Question by:Buhrj1
    1 Comment
    LVL 11

    Accepted Solution

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now