Reputation: 1678
I am working with a DataGridView
in winforms that I am handling the CellPainting
event for to paint all the cells myself.
My grid is virtual and has all of it's data stored in a custom data structure centered around a MemoryStream
.
All of my painting has been going fine, until a user Shift + clicks to select a large range of cells at once (25,000+), which have to be added to a selected cells collection, have a bunch of flags set, and other performance-draining operations.
Is there any way to prevent the DataGridView from "selecting" a cell so I can handle this operation separately in a more efficient manner?
Upvotes: 2
Views: 850
Reputation: 85996
A bit confused on the issue here.
If you don't want them to be able to select multiple-cells at all, set
dataGridView.MultiSelect = false
You say they ctrl+click 25k cells - are you suggesting they select 25k cells one-at-a-time (that is how ctrl+click works)? If you mean they shift-click to select a range, then simply handle the SelectionChanged
event, and do whatever you need to do with dataGridView.SelectedRows
. SelectionChanged
will only be called once, for the entire selection.
Upvotes: 2