Hello can you help me please i got problem in using the list view,I don't know how to use it

First i want to know how to make header and populate records in my recordset...or display all the records...can you help me please.Thank you in advance hoping for your positive response....

your post is not clear..
what dbms are u using? access? mssql? mysql?
how far u doing this? show your effort first..

You need to read this .

your post is not clear..
what dbms are u using? access? mssql? mysql?
how far u doing this? show your effort first..

Hi sir thank you for the reply it's MS ACCESS, I have nOt yet coded sir because i don't have yet idea to write it....Please help me sir thank you in advance hoping for your positive response.

You need to read this .

hi sir thanks for the link i will write again sir if i get trouble...more power to you.

You need to read this .

Sir, can you show me some example in listview sir i really want to learn on this sir...Thank you in advance hoping for your positive response...

this an example to load data into list view :

Public Conn As New ADODB.Connection
Public rs As New ADODB.Recordset

Private Sub Access_Connector()
    Set Conn = New ADODB.Connection
    Conn.Provider = "microsoft.jet.oledb.4.0"
    Conn.CursorLocation = adUseClient
    Conn.Open App.Path & "\Authors.mdb"
End Sub
Private Sub SetListView(LSV As ListView, ParamArray lstview())
    Dim i, width
    LSV.View = lvwReport
    width = LSV.width - 80
    With LSV.ColumnHeaders
        .Clear
        For i = 0 To UBound(lstview) - 1 Step 2
        .Add , , lstview(i), (lstview(i + 1) * width) / 100
        Next i
    End With
End Sub
Private Sub GetData(LSV As ListView)
Call SetListView(LSV, "Author Id", 25, "Author Name", 40, "Birth date", 35)
            
    'Set rs = New ADODB.Recordset
    rs.Open "SELECT * from Authors", Conn, adOpenDynamic, adLockBatchOptimistic
    
    LSV.ListItems.Clear
    
    While Not rs.EOF
        Set View = LSV.ListItems.Add
        View.Text = rs!Au_id
        View.SubItems(1) = rs!Author
        View.SubItems(2) = rs!YearBorn
        rs.MoveNext
    Wend
    rs.Close
    
End Sub

Private Sub Command1_Click()
GetData ListView1
End Sub

Private Sub Form_Load()
Access_Connector
End Sub

this an example to load data into list view :

Public Conn As New ADODB.Connection
Public rs As New ADODB.Recordset

Private Sub Access_Connector()
    Set Conn = New ADODB.Connection
    Conn.Provider = "microsoft.jet.oledb.4.0"
    Conn.CursorLocation = adUseClient
    Conn.Open App.Path & "\Authors.mdb"
End Sub
Private Sub SetListView(LSV As ListView, ParamArray lstview())
    Dim i, width
    LSV.View = lvwReport
    width = LSV.width - 80
    With LSV.ColumnHeaders
        .Clear
        For i = 0 To UBound(lstview) - 1 Step 2
        .Add , , lstview(i), (lstview(i + 1) * width) / 100
        Next i
    End With
End Sub
Private Sub GetData(LSV As ListView)
Call SetListView(LSV, "Author Id", 25, "Author Name", 40, "Birth date", 35)
            
    'Set rs = New ADODB.Recordset
    rs.Open "SELECT * from Authors", Conn, adOpenDynamic, adLockBatchOptimistic
    
    LSV.ListItems.Clear
    
    While Not rs.EOF
        Set View = LSV.ListItems.Add
        View.Text = rs!Au_id
        View.SubItems(1) = rs!Author
        View.SubItems(2) = rs!YearBorn
        rs.MoveNext
    Wend
    rs.Close
    
End Sub

Private Sub Command1_Click()
GetData ListView1
End Sub

Private Sub Form_Load()
Access_Connector
End Sub

Hi sir thank you for this example i will try this sir...thank you again and more power to you.

okay,,don't forget to give a feedback

You need to read this sample.

Hello sir can i ask something of this what is the purpose of this code sir I am confuse with this Please help me sir Thank you in advance hoping for your positive response..
I found it in this link.http://http://www.vb6.us/tutorials/using-ado-and-listview-control-vb6


here is the code sir...

Option Explicit
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Sub SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)

this an example to load data into list view :

Public Conn As New ADODB.Connection
Public rs As New ADODB.Recordset

Private Sub Access_Connector()
    Set Conn = New ADODB.Connection
    Conn.Provider = "microsoft.jet.oledb.4.0"
    Conn.CursorLocation = adUseClient
    Conn.Open App.Path & "\Authors.mdb"
End Sub
Private Sub SetListView(LSV As ListView, ParamArray lstview())
    Dim i, width
    LSV.View = lvwReport
    width = LSV.width - 80
    With LSV.ColumnHeaders
        .Clear
        For i = 0 To UBound(lstview) - 1 Step 2
        .Add , , lstview(i), (lstview(i + 1) * width) / 100
        Next i
    End With
End Sub
Private Sub GetData(LSV As ListView)
Call SetListView(LSV, "Author Id", 25, "Author Name", 40, "Birth date", 35)
            
    'Set rs = New ADODB.Recordset
    rs.Open "SELECT * from Authors", Conn, adOpenDynamic, adLockBatchOptimistic
    
    LSV.ListItems.Clear
    
    While Not rs.EOF
        Set View = LSV.ListItems.Add
        View.Text = rs!Au_id
        View.SubItems(1) = rs!Author
        View.SubItems(2) = rs!YearBorn
        rs.MoveNext
    Wend
    rs.Close
    
End Sub

Private Sub Command1_Click()
GetData ListView1
End Sub

Private Sub Form_Load()
Access_Connector
End Sub

Hi sir can i ask what is the purpose of ubound?and what is ParamArray?.please help me sir. Can I ask favor can you put some comment of your code so that it can help me more and so that i can understand.Thank you in advance hoping for your positive response...

Option Explicit
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Sub SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)

this is an API functions..
this function used to disable x button on the form, lock and unlock window, top most the form..
you can find that procedure on the listing program..

Hi sir can i ask what is the purpose of ubound?and what is ParamArray?.please help me sir. Can I ask favor can you put some comment of your code so that it can help me more and so that i can understand.Thank you in advance hoping for your positive response...

ParamArray lstview : declare lstview as array.
Sometimes we need a procedure that can accepts a variable number of arguments at various times during program( it means the procedure is sometimes called by passing one argument and at some later time same procedure can be called by passing two arguments etc.).
In this case we use the keyword ParamArray in definition header of the procedure that requires the variable number of arguments at various times.
We put this keyword in the parameter list that indicates that this procedure will receive a variable number of arguments.

UBound() : to determine the highest available subscript for the indicated dimension of an array. you can know how many index in lstview (an array). so you can know how many headers that u have to created.

this is an API functions..
this function used to disable x button on the form, lock and unlock window, top most the form..
you can find that procedure on the listing program..

Hi sir, Thank you for the reply, so this is used to disable the button minimize,maximize?am i correct sir...okay sir..Thank you again and more power to you...

ParamArray lstview : declare lstview as array.
Sometimes we need a procedure that can accepts a variable number of arguments at various times during program( it means the procedure is sometimes called by passing one argument and at some later time same procedure can be called by passing two arguments etc.).
In this case we use the keyword ParamArray in definition header of the procedure that requires the variable number of arguments at various times.
We put this keyword in the parameter list that indicates that this procedure will receive a variable number of arguments.

UBound() : to determine the highest available subscript for the indicated dimension of an array. you can know how many index in lstview (an array). so you can know how many headers that u have to created.

okay sir ParamArray is keyword and this is how to declare an array in vb6.0 sir?

Hi sir, Thank you for the reply, so this is used to disable the button minimize,maximize?am i correct sir...okay sir..Thank you again and more power to you...

u don't have to use api function to disable minimize and maximize,
there are properties in form to disable minimize and maximize button.

Please keep the thread on the topic only (lstview) .

Please start a new thread for a new question and mark the thread as solved if your question is already answered.

okay sir ParamArray is keyword and this is how to declare an array in vb6.0 sir?

ParramArray used to array with various parameter.

an example of array declare :
Dim NewArray() as Integer ' array with integer data type
Dim NewArray() as String ' array with string data type

u need to read this site about declare an array

actually if u have another question about vb then please create a new thread.
if u question already answered then please mark this thread as solved..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.