473,467 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

UnSelect a Modifier Key For ListView SelectAll

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.
Sep 6 '08 #1
1 2619
On Sep 5, 5:53*pm, NvrBst <nvr...@gmail.comwrote:
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.
Encase someone else runs into a similar problem, I was able to remove
the "Thread.Sleep(...)" delay by changing the "SendKeys.Send("{END}+
{HOME}");" to the following:
listView1.Items[lastElement].Selected = true;
SendKeys.Send("+{HOME}");
This way even if the ctrl key is still being held down, it'll select
all the element. However, if you select an element, and then hit the
"ctrl-a" function quickly after, it sometimes re-selects the 1st
element after it selects all (thus unselected all the elements), which
I can't explain. It doesn't happen to often though. I think if I
could change it to something like

listView1.Items[lastElement].Selected = true;
SendKeys.Send("+"); //ShiftKey Down
listView1.Items[0].Selected = true;
//ShiftKey Up

I'd like it best (it keep the user where they are origionally, and
probably fix the problem I labeled before). Is there an simple/fast
way to send a ShiftKey Down / ShiftKey Up message? I couldn't find
how to do it with SendKeys.

Thanks
Sep 12 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: bullshark | last post by:
VSN03:C# Create a C# Windows Form project. Add two TextBox controls. From the Properties of each, add an Enter Event handler. In the generated Enter Event Handlers (textBox1_Enter &...
10
by: Wayne Wengert | last post by:
In the GotFocus event for several text boxes I include code such as "txtMyTxtBox.SelectAll". When I tab from textbox to textbox the text in the textbox that got focus is selected as expected but if...
0
by: Shane | last post by:
I've modified the standard text box to change the background color on the "Enter" event and to change the color back to the original value on "Leave". I've also added a bunch of other methods and...
3
by: Stefan Mueller | last post by:
I've an input box <input type = "text" name = "MyInput" value = ""> and a selection <select name = "MySelection" size = "1"> <option value = "1">Entry 1 <option value = "2">Entry 2 </select>...
1
by: Sean | last post by:
In windows forms textbox1.focus() textbox1.SelectAll() makes the text in the textbox selected when the above is run What is the ASP.NET version of the same task becuase Texboxes do not have...
2
by: Stefan Mueller | last post by:
I've a ListView in ReportMode with MultiSelect = False. If the user enters a number I select the appropriate item in the ListView. If the used enters a number which is not in the ListView I'd...
6
by: sesling | last post by:
I have several forms that use list boxes. These list boxes are used to pass information to command line. The operator is not required to select an item from each box. See below ListBox1 -...
3
by: Joe Cool | last post by:
I have a ListBox on a form than has some items. The select mode is one item only. I select one, it is selected and hightlighted. I then click somewhere in the listbox not on any item, in the clear...
1
by: Eek | last post by:
Hi everyone; I have a strange problem with a DataGridView bound to a BindingList. The grid is populated asynchronously by a thread which, when it completes, refreshes the grid by doing an Invoke...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.