Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag
Go Back  Xtreme Visual Basic Talk > > > Easy Listview checkbox selection by drag


Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2012, 01:31 PM
Gruff's Avatar
GruffEasy Listview checkbox selection by drag Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default Easy Listview checkbox selection by drag


Easy Listview checkbox selection by drag.

The Listview multiselect for checkboxes leaves a lot to be desired in ReportView.
Shift-LM-Drag or Ctrl-LM-Select Toggles item checkboxes,
but the results are not always what you would expect.

Instead I've found a cleaner way to work with checkboxes in listview.

The following code allows the listview checkboxes:
1) To be toggled by single click on the checkbox.
2) To be drag checked by left mouse drag in the first column
3) To be drag unchecked by right mouse drag in the first column.
4) Individual line items may be single click selected outside the first column without toggling.

Listview properties set:
multiselect = false
checkboxes = true
fullrowselect = true

This option could be rewritten as an inherited control.

Code:
Dim DragCheck As TriState = TriState.UseDefault Private Sub ListView1_MouseDown(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseDown If e.X < ListView1.Columns(0).Width Then ' Only use on first column. Select Case e.Button Case Windows.Forms.MouseButtons.Left DragCheck = TriState.True Case Windows.Forms.MouseButtons.Right DragCheck = TriState.False End Select End If End Sub Private Sub ListView1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseMove If e.X < ListView1.Columns(0).Width Then ' Only use on first column. If ListView.GetItemAt(e.X, e.Y) Is Nothing Then Exit Sub If e.Button = Windows.Forms.MouseButtons.Left Or e.Button = Windows.Forms.MouseButtons.Right Then If DragCheck <> TriState.UseDefault Then ListView1.GetItemAt(e.X, e.Y).Checked = CBool(DragCheck) End If End If End If End If End Sub Private Sub ListView1_MouseUp(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles ListView1.MouseUp DragCheck = TriState.UseDefault End Sub
Have fun.
__________________
Burn the land and boil the sea
You can't take the sky from me


~T

Last edited by Gruff; 02-09-2012 at 02:33 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag
 
Easy Listview checkbox selection by drag
Easy Listview checkbox selection by drag
 
-->