I have a multi-column ListView control set to MultiSelect and Details view. When a user clicks on any item on the list, I want to treat it as if they CTRL+clicked on the item. So, if they click on an item that is already selected, it will deselect it. Or, if they select a second item, it will select it without deselecting other selected items. This is for a kiosk-style app, where input is done via touch screen and a keyboard may or may not be available to the user.
You can do that by handling MouseUp
event and use HitTest
to check which item has been clicked. Then set Selected property of the item:
item.Selected ^= true
You may also check out freeware component Better ListView Express from ComponentOwl. It has powerful owner drawing that allows you to display items in any state . It also allows you to customize height of items. The full version offers even more interesting features.
You might consider using ListBox
instead, in owner drawn mode.
http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.aspx
and
http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.drawmode.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.