Solved

What must be done to refresh a dataGridView with the most recent line inserted?

Posted on 2014-01-23
1
247 Views
Last Modified: 2014-01-25
Hi Experts!

My form has a tabcontrol with 02 pages

In the 1st page a line of data could be saved.

The 2nd. page has a dataGridView that must present the most recent line inserted when fired.

But now the dataGridView isn't refreshed accordingly to:

        private void tabPage2_Click(object sender, EventArgs e)
        {
            dataGridView.Refresh(); 
        }

Open in new window


So, I have to close the form and reenter in it to see the line recently inserted...

What (else) must be done?

Thanks in advance!
0
Comment
Question by:Eduardo Fuerte
1 Comment
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 total points
Comment Utility
Refresh forces the grid to redraw itself, it does not refresh the data.

If the grid is databound, set its DataSource to Nothing. If it was filled with code, calls DataGridView1.Rows.Clear to empty it.

Then rerun the code that you used to fill the grid.

It will refresh without having to close and open the form.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

7 Experts available now in Live!

Get 1:1 Help Now