I have a ListView (VirtualMode) and I want to implement a SelectAll.
--1st Atempt--
The standard for loop takes way to long: "for(int i = 0; i <
listView1.VirtualListSize - 1; i++)
listView1.SelectedIndices.Add(i);". I've tried wrapping the above
statment in a "listView1.SuspendLayout() /
listView1.ResumeLayout(false)" but it didn't help. 3000 Elements
takes about 15 seconds to select with this.
--2nd Atempt--
I then tried "SendKeys.Send("{END}+{HOME}");" which works fast,
however, it only works when I click the menu item; it has a HotKey
"Ctrl-A", and when I use that what my listView is processing is the
"Ctrl-End, Shift-Home", which doesn't select all element (ctrl-end
moves the scroll bar). 3000 Elements takes about 1 seconds to select
with this.
--3rd Atempt--
I see a
"System.Windows.Forms.ListView.ReflectMessage(list View1.Handle, ?
Message?);" which might be what I want to use but think it might just
act the same as SendKeys.Send(...)...
--Questions--
Would "3rd Atempt" be the way to send the "END, SHIFT-HOME" and bypass
the ctrl key? Or it'd end up with same result as SendKeys?
Is there a way to send the "ctrl up" message, eventhough the user may
still be holding it down, before/during the "SendKeys.Send"?
Is there an easier way to add all the elements to the SelectedIndices
at once (IE like AddRange)? Or a better way to select all elements,
or something I can wrap around the "for loop ->
SelectedIndices.Add(...)" so that it doesn't process whatever it's
processing?
Currently I just add a "Thread.Sleep(500);" before the
"SendKeys.Send", which works okay, however, would like to update it
incase the user is holding down the ctrl key for a long time. Thanks.