Note that there are some explanatory texts on larger screens.

plurals
  1. PODataGridView resets Scroll&Select on Update
    text
    copied!<p>I have a problem with my datagridview: when i update my datagridview with BindingSource.ResetBindings(false) it drops select on my cells and drops scrollbar to the beginning.</p> <p>I tried to save selected cells to temp and then try select them again, but if I keep mouse button pressed then, when I refresh table, selections zone start cells moves to beginning.</p> <p>And I tried to save scrollbars states with saving DGV.FirstDisplayedScrollingColumnIndex and DGV.FirstDisplayedScrollingRowIndex but it doesn't work very smooth.</p> <p>Does somebody know more elegant solution?</p> <p>Current Solution:</p> <pre><code> private List&lt;Cell&gt; selectedCells; private Cell ShowCell; public void SaveSelections(DataGridView dgv) { if (dgv.Rows.Count == 0) return; ShowCell = new Cell(dgv.FirstDisplayedScrollingColumnIndex, dgv.FirstDisplayedScrollingRowIndex); selectedCells = new List&lt;Cell&gt;(); foreach (DataGridViewCell c in dgv.SelectedCells) { selectedCells.Add(new Cell(c.ColumnIndex, c.RowIndex)); } } public void LoadSelections(DataGridView dgv) { if (dgv.Rows.Count == 0 || ShowCell == null) return; dgv.FirstDisplayedScrollingRowIndex = ShowCell.Row; dgv.FirstDisplayedScrollingColumnIndex = ShowCell.Column; dgv[0, 0].Selected = false; foreach (Cell c in selectedCells) { dgv[c.Column, c.Row].Selected = true; } } </code></pre> <p>It doesn't work smooth and elegent, scrollbars are always twitching and multi-select doesn't work correctly if selecting cells and update happens in the same time</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload