¿Cómo puedo actualizar una tabla de datos y una cuadrícula de forma asincrónica?

I'm using a DevExpress XtraGrid component and a DataTable as the data source.

I'd like to update the data (asynchronously) every few seconds but I don't want to scroll/collapse/change the grid.

For example, if a user has scrolled the grid and I perform a background update, then I want the user to stay on the same row, etc.

preguntado el 08 de noviembre de 11 a las 13:11

1 Respuestas

I think that you can use the following approach:

  1. Utilizan BindingSource as a datasource for GridControl and disable BindingSource.RaiseListChangedEvents option. This will allow you to prevent your datasource from sending notifications to GridControl. As a result, GridControl will not update itself automatically on each change.

  2. On updating your datasource, save updated row indexes.

  3. Finally, introduce a timer with interval equal, for example, five seconds, and call the RefreshRow method to refresh only requiered rows. Also, you can refresh all rows using the RefreshDataSource method.

As a result, you will update only required rows once in five seconds and row states will be saved.

respondido 09 nov., 11:14

This works well unless you have a large number of rows, at which point any refresh seems to lock up the UI. - jnm2

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.