'How can I set the selected set of c# datagridview cells from a saved set of SelectedCells

I have a datagridview that has a set of selected cells (DataGridView.SelectedCells). The values are used to filter and redisplay the datagridview. After the datagridview is redisplayed I want to set the cells used for the filtering back to the selected state.

I have tried saving the set of selected cells and then setting the property back after the filtering is done. However it appears that the SelectedCells property is read-only.

Is there programmatic way of doing this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source