Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 132,165 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,633 people online right now. Registration is fast and FREE... Join Now!




Listview

 
Reply to this topicStart new topic

Listview

masipro
post 18 Aug, 2008 - 03:28 AM
Post #1


New D.I.C Head

*
Joined: 8 Jul, 2008
Posts: 36

hai,

I have listview in VB6 and i am confused how to use it. Assume if I have to display a recordset in listview how to code. Though i used it but some properties to be initialized in code first then only it will work. Please let me know with an example . Thank you,

masipro
User is offlineProfile CardPM

Go to the top of the page

Zeldo
post 18 Aug, 2008 - 10:13 AM
Post #2


New D.I.C Head

*
Joined: 18 Aug, 2008
Posts: 2

What I think your asking, is how to use a ListView. Here are some basics.

CODE
ListView.ListItems().Add Index, Key, Text, Icon, SmallIcon


This will add a item to your listview, All of those fields are optional.

To get info from a list item you would simply

CODE
ListView.ListItems(INDEX).OptionHere


for example if I wanted to know what the index 1 said I would do

CODE
ListView.ListItems(1).Text


Hope this helps.

This post has been edited by Zeldo: 18 Aug, 2008 - 10:16 AM
User is offlineProfile CardPM

Go to the top of the page

tope10
post 18 Aug, 2008 - 08:55 PM
Post #3


New D.I.C Head

*
Joined: 25 Jun, 2008
Posts: 22



Thanked 2 times
My Contributions


QUOTE(masipro @ 18 Aug, 2008 - 04:28 AM) *

hai,

I have listview in VB6 and i am confused how to use it. Assume if I have to display a recordset in listview how to code. Though i used it but some properties to be initialized in code first then only it will work. Please let me know with an example . Thank you,

masipro


here is a sample code for your problem.
all you have to do is set first the column by right clicking the list view and go to properties the click the column header tab. then on that tab you can add now the column.

here in this code the name of the listview control is lvwbook.
vb

Dim lst As ListItem
lvwBook.ListItems.CLEAR
Dim ChkTime As Date
Dim dtdate As Date
Set rsOverdue = New ADODB.Recordset
rsOverdue.Open "qryBorrowed", cn, adOpenDynamic, adLockBatchOptimistic

If rsOverdue.RecordCount <> 0 Then

Do While Not rsOverdue.EOF
Set lst = lvwBook.ListItems.Add(1)
lst.Text = rsOverdue.Fields!AccessionNo
lst.SubItems(1) = rsOverdue.Fields!Title
rsOverdue.MoveNext
loop

Set rsOverdue = Nothing
End If
User is offlineProfile CardPM

Go to the top of the page

tweety0012coo
post 28 Aug, 2008 - 05:11 PM
Post #4


New D.I.C Head

*
Joined: 24 Jun, 2008
Posts: 3


My Contributions


hello there!!!!!
i hope this
code will help you..

**this code is where you can view your data from database. im using MYSQL.
CODE
Public rs As New ADODB.Recordset

If rs.State <> 0 Then rs.Close
    rs.Open "select * from Company ", db, 3, 3
    If rs.RecordCount = 0 Then
        ListView1.ListItems.Clear
        Exit Sub
    Else
    rs.MoveFirst
    ListView1.ListItems.Clear
    While Not rs.EOF
        With ListView1.ListItems.Add(, , rs!CompanyNumber)
            .ListSubItems.Add , , rs!CompanyCode
            .ListSubItems.Add , , rs!CompanyName
            .ListSubItems.Add , , rs!Address)
            rs.MoveNext
        End With
    Wend
End If
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/21/08 02:53PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month