Solved

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

Posted on 2014-01-23
1
259 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 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

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…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

734 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