Skip to content

DevExpress-Examples/wpf-data-grid-edit-form-pause-updates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Data Grid for WPF - How to Pause Data Updates in the Edit Form

This example illustartates how to pause data updates when a user edits a row in the Edit Form. To do that, handle the RowEditStarted and RowEditFinished events. Alternatively, you can create commands in a View Model and bind them to the RowEditStartedCommand and RowEditFinishedCommand properties.

In this example, the GridControl updates data on a timer. The UpdateRows() function updates data depending on the updatesLocker value. When a user starts to edit a row, the RowEditStarted event occurs. The event handler sets the updatesLocker value to true to lock data updates. When the user finished editing the row, RowEditFinished occurs and the event handler unlocks updates.

bool updatesLocker;
// ...
private void OnRowEditStarted(object sender, RowEditStartedEventArgs e) => Volatile.Write(ref updatesLocker, true);

private void OnRowEditFinished(object sender, RowEditFinishedEventArgs e) => Volatile.Write(ref updatesLocker, false);

void UpdateRows(object parameter) {
    if(!Volatile.Read(ref updatesLocker)) {
        var row = data[random.Next(0, data.Count)];
        if(row.ShouldUpdate) {
            row.Value = random.Next(1, 100);
        }
    }
}

In the TreeListView, use the following events and properties:

Files to Look At

Code-Behind

MVVM Pattern

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)