Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-01-23
1
Medium Priority
?
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Setting up LaraDock for Laravel

Learn how to set up LaraDock in a Laravel project - LaraDock gives us an easy way to run a Laravel application using Docker in a single command.

Question has a verified solution.

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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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