hi i have a problem puting a column header to my listview did not affair to my listview


here's my code

Private mobjConn                As ADODB.Connection
Private mobjCmd                 As ADODB.Command
Private mobjRst                 As ADODB.Recordset
Private Sub Form_Load()
Call SetupCustLVCols
Set mobjConn = New ADODB.Connection
If mobjConn.State = 1 Then con.Close
mobjConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
            App.Path & "\jpg.mdb"
 Set mobjCmd = New ADODB.Command
    Set mobjCmd.ActiveConnection = mobjConn
    mobjCmd.CommandType = adCmdText
End Sub
Private Sub SetupCustLVCols()
  With ListView1
        .ColumnHeaders.Add , , "Last Name", .Width * 0.12
        .ColumnHeaders.Add , , "First Name", .Width * 0.15
        .ColumnHeaders.Add , , "Idnumber", .Width * 0
        .ColumnHeaders.Add , , "Address", .Width * 0.2
        .ColumnHeaders.Add , , "Gender", 0
    End With
End Sub
Private Sub LoadCustomerListView()
    Dim strSQL As String
    Dim objCurrLI As ListItem
    
    ClearCommandParameters
    mobjCmd.CommandType = adCmdStoredProc
    mobjCmd.CommandText = "SelectStudent"
    
    ListView1.ListItems.Clear
    
    
End Sub

Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
With ListView1
 If (.Sorted) And (ColumnHeader.SubItemIndex = .SortKey) Then
            If .SortOrder = lvwAscending Then
                .SortOrder = lvwDescending
            Else
                .SortOrder = lvwAscending
            End If
        Else
            .Sorted = True
            .SortKey = ColumnHeader.SubItemIndex
            .SortOrder = lvwAscending
        End If
        .Refresh
    End With
     If Not ListView1.SelectedItem Is Nothing Then
        ListView1.SelectedItem.EnsureVisible
    End If

End Sub

Just set view property to lvwReport - that is all. Btw - you can see it at runtime, not in design time - this is VB6, not .NET

This article has been dead for over six months. Start a new discussion instead.