Solved

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

Posted on 2014-01-23
1
253 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
ID: 39804468
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

831 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