Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Jan 4, 2002

Select a Whole Row in Any ListView


Only in VB6 do the common controls OCX files provide an option to select a full line in a listview. In earlier versions, you can select a ListItem only by clicking on the left-most column. This code allows the user to click anywhere on the line to select and highlight the ListItem:
 
Private Sub ListView1_MouseDown(Button As _
Integer, Shift As Integer, x As Single, y _
As Single)
Dim itm As ListItem
Dim i As Long
With ListView1
Set .DropHighlight = _
.HitTest(Screen.TwipsPerPixelX * 2, y)
Set itm = .HitTest(Screen. _
TwipsPerPixelX * 2, y)
Set .SelectedItem = itm
' Use the following if you have code
' to execute on a user click.
For i = 1 To .ListItems.Count Step 1
If .ListItems(i).Selected Then
Call ListView1_ItemClick _
(.ListItems(i))
Exit For
End If
Next i
End With
End Sub
Alex Whyte
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date