Abundant Technologies - IT Consulting Experts

 Source Code Library

 Code Details

     
'Get the test project with the "Test this code" link Option Explicit Private Declare Function SendMessage Lib "user32" Alias _ "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal _ wParam As Long, lParam As Any) As Long Const LVS_EX_FULLROWSELECT = &H20 Const LVM_FIRST = &H1000 Const LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + &H37 Const LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + &H36 Private Sub Command1_Click() ListView1.ListItems.Clear End Sub Private Sub Form_Load() Dim clmAdd As ColumnHeader Dim itmAdd As ListItem Dim imgX 'Add two Column Headers to the ListView control Set clmAdd = ListView1.ColumnHeaders.Add(Text:="Name") Set clmAdd = ListView1.ColumnHeaders.Add(Text:="Test") Set clmAdd = ListView1.ColumnHeaders.Add(Text:="Date") 'Set the view property of the Listview control to Report view ListView1.View = lvwReport 'Add data to the ListView control Set itmAdd = ListView1.ListItems.Add(Text:="111111") itmAdd.SubItems(1) = "test" itmAdd.SubItems(2) = "05/07/97" Set itmAdd = ListView1.ListItems.Add(Text:="Joe") itmAdd.SubItems(1) = "test" itmAdd.SubItems(2) = "05/07/97" Set itmAdd = ListView1.ListItems.Add(Text:="Sally") itmAdd.SubItems(1) = "test" itmAdd.SubItems(2) = "04/08/97" Set itmAdd = ListView1.ListItems.Add(Text:="Bill") itmAdd.SubItems(1) = "test" itmAdd.SubItems(2) = "05/29/97" Set itmAdd = ListView1.ListItems.Add(Text:="Fred") itmAdd.SubItems(1) = "test" itmAdd.SubItems(2) = "05/17/97" Set itmAdd = ListView1.ListItems.Add(Text:="Anne") itmAdd.SubItems(1) = "test" itmAdd.SubItems(2) = "04/01/97" Dim lStyle As Long lStyle = SendMessage(ListView1.hwnd, _ LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0) lStyle = lStyle Or LVS_EX_FULLROWSELECT Call SendMessage(ListView1.hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, _ 0, ByVal lStyle) Set imgX = ImageList1.ListImages. _ Add(, , LoadPicture(App.Path & "\checkbox.gif")) ListView1.SmallIcons = ImageList1 End Sub Private Sub ListView1_DblClick() MsgBox "Found " & ListView1.SelectedItem ListView1.ListItems(ListView1.SelectedItem.Index).SmallIcon = 1 End Sub Private Sub ListView1_ColumnClick(ByVal ColumnHeader As ColumnHeader) ' When a ColumnHeader object is clicked, the ListView control is ' sorted by the subitems of that column. ' Set the SortKey to the Index of the ColumnHeader - 1 ListView1.SortKey = ColumnHeader.Index - 1 If ListView1.SortOrder = 0 Then ListView1.SortOrder = lvwDescending Else ListView1.SortOrder = lvwAscending End If ' Set Sorted to True to sort the list. ListView1.Sorted = True End Sub

Mail To: info@3pc.com