We help IT Professionals succeed at work.
Get Started

Refresh DataGridView in multi user environment

nsfranklin asked
Last Modified: 2008-01-09

I have a datagrid view that display data that has to be released by users.

The program access a MySQL database and data is bound to the datagrid

Dim da As MySqlDataAdapter = New MySqlDataAdapter("SELECT * FROM " & myProject & " WHERE period = '" & myPeriod & "' AND status = 'New' ORDER by siteref", myconn)
da.Fill(ds, myProject)
DataGridView.DataSource = ds.Tables(0)

As multiple users are releasing data, I would like the datagrid to periodically refresh to remove data that other users have released, and add data that has been added since the last refresh.

I have got it working in principle, however the cursor position in the datagrid (i.e the record the user has selected) resets to the first record in the datagrid after the refresh.

How can I maintain the currently selected row and re-select that row after the refresh, bearing in mind that records could be added or removed both above and below the selected row.

Watch Question
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE