Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Selecting an entire row in a ListView

Total Hit ( 3641)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


The ListView control that comes with VB6 lets you select an entire row by setting its FullRowSelect property to True. If you are working with VB5 or you're using VB6 with the old version of the Microsoft Windows Controls this capability isn't avaible, but if you have installed the comctl32.dll version 4.70 or greater (shipped with IE3.x or greater), you can implement it by just setting a given ListView style bit. You can achieve that by sending the message LVS_EX_FULLROWSELECT to the control. Here's the routine to set this new property:

Click here to copy the following block
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
  hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, _
  lParam As Any) As Long
Const LVM_FIRST = &H1000
Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54
Const LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55
Const LVS_EX_FULLROWSELECT = &H20

Sub SetFullRowSelection(ByVal hWndListView, ByVal bFullRow As Boolean)
  SendMessageLong hWndListView, VM_SETEXTENDEDLISTVIEWSTYLE, _
    LVS_EX_FULLROWSELECT, ByVal CLng(bFullRow))
End Sub

This is an example of how you can use this routine:

Click here to copy the following block
' enable full row selecting
SetFullRowSelection ListView1.hwnd, True
' disable full row selecting
SetFullRowSelection ListView1.hwnd, False


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.