refresh form with datagridview

Posted on 2012-08-27
Last Modified: 2012-08-29
I have a windform with DataGridView display a list of data with a DataGridViewButtonColumn. When I clicked the button, a popup window will display some info and I could make changes. And after I clicked a button in popup. Some data updated in DB. And popup closed. But the content of my DataGridView in first firm should have changed. But not updated I could not see the changes I made. I know I should update the form or the datasource of DataGridView so that I could see the changes after the popup closed. I tried this.update(); this.refresh(); invalidate.....Just not working correctly.
But It worked if I reload the form. The problem is I don't want to reload the whole form?

How to handle it? Appreciated!!
Question by:jssong2000
    LVL 16

    Accepted Solution


    Try this simple way.

    in Form1, Write the data binding code in a subroutine

    and at the end of the button click which is used to open popup form, call the binding subroutine process.

    This will refresh the datagridview.

    Try like this.

    namespace WinAppCSHARP
        public partial class Form1 : Form
            public Form1()
            private void Form1_Load(object sender, EventArgs e)
            public void BindGrid()
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = YourDataSource;            
            private void btnOpenPopup_Click(object sender, EventArgs e)
    	    // Opens Popup window
                frmPopup frm = new frmPopup();
    	    // Load DataGridView again

    Open in new window


    Author Closing Comment

    It worked. Thank You!!!

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
    Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
    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.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    755 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

    19 Experts available now in Live!

    Get 1:1 Help Now