Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-01-23
1
Medium Priority
?
262 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 2000 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

916 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