Refresh DataGridView

Posted on 2008-11-04
Last Modified: 2008-11-16
Im working with MDI forms. I have two child forms 1 as a master & 2 as detail. The DataGridView is on Form1. When I make a change in form2 I would like to rebind or refresh the datagridView in Form1.

Question by:u2envy1
    LVL 2

    Expert Comment

    You could do it like this:

    It is likely that you also have to end edit if any has been commenced:

    Or you can refresh your bindingsource:


    Author Comment

    That is not going to help if I refresh from another form.
    This is what I have but im refreshing a different instance of Frm1
    Frm1 frm1 = new Frm1 ();
    LVL 2

    Expert Comment

    Yeah, you can't (directly) refresh a control on another form. I took a look at the following link which  talks about how do call methods from outside their creation thread:

    As it says: "The STA model requires that any methods on a control that need to be called from outside the control's creation thread must be marshaled to (executed on) the control's creation thread. The base class Control provides several methods (Invoke, BeginInvoke, and EndInvoke) for this purpose. Invoke makes synchronous method calls; BeginInvoke makes asynchronous method calls."

    Hope this might help.

    Author Comment

    How do I use (Invoke, BeginInvoke, and EndInvoke)  with a frm1.dgvAppraisal.Refresh(); ?
    Is their no way I can get the control form the current instance & not creating a new instance of the form ?
    LVL 26

    Accepted Solution

    use events and delegates to update datagrid on the first page when some data is updated from second page and you come back again on first page
    have a look at the following

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    In one of my recent projects, I was working with IP cameras, I need to take some pictures from the camera and do some processing on it. The first step, was to retrieve the image from camera into Image object. So that it can be displayed or …
    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    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.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    760 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

    10 Experts available now in Live!

    Get 1:1 Help Now