Skip to main content
All docs
V22.2

CRXPF0015 - BeginUpdate call in a loop

Severity: Info

The analyzer detects that you call the BeginUpdate method in a loop. In this case, the collection processes updates in each cycle separately.

Examples

Invalid Code

for ... || foreach ... || while ... || any cycle {
    _gridControl.Columns.BeginUpdate();
    _gridControl.Columns.Add(_newColumn1);
    _gridControl.Columns.Add(_newColumn2);
    _gridControl.Columns.EndUpdate();
}

Valid Code

_gridControl.Columns.BeginUpdate();
for ... || foreach ... || while ... || any cycle {
    _gridControl.Columns.Add(_newColumn1);
    _gridControl.Columns.Add(_newColumn2);
}
_gridControl.Columns.EndUpdate();

How to Fix

Call the BeginUpdate and EndUpdate methods outside a loop to process all updates in one batch and increase performance.