PDA

Click to See Complete Forum and Search --> : How does ListView work? Please help


Rodik
Jan 26th, 2000, 03:49 PM
I don't know how to add items to a listview, I probably don't know anything about it and I can't find anything inte the help other than what commands there are (but not how to use them with ListView). Please, If you know any place where I can find some information about how using a listview, tell me...

The "vital" things I need to know is how to clear the list and how to add to it.. (and it's columns)....

Thanks :

Mark Sreeves
Jan 26th, 2000, 05:15 PM
Right, here goes!

You can add columns either through the property pages or in code


Private Sub Form_Load()

' Add ColumnHeaders. The width of the columns is
' the width of the control divided by the number of
' ColumnHeader objects.
ListView1.ColumnHeaders. _
Add , , "col1", ListView1.Width / 3
ListView1.ColumnHeaders. _
Add , , "col2", ListView1.Width / 3, _
lvwColumnCenter
ListView1.ColumnHeaders. _
Add , , "col3", ListView1.Width / 3
' Set View property to Report.
ListView1.View = lvwReport
End Sub


to add data to rows you have to add a list item.

data in subsequent columns are sub items of the list item:

Private Sub Command1_Click()
Dim itmx As ListItem

Set itmx = ListView1.ListItems.Add(, , "somthing in col1")
' SubItem 1 to it.

itmx.SubItems(1) = "something in col2"



' SubItem 2 to it.

itmx.SubItems(2) = "somethinmg in col3"


End Sub


hope this helps

------------------
Mark Sreeves
Analyst Programmer

Mark.Sreeves@Softlab.co.uk
A BMW Group Company


[This message has been edited by Mark Sreeves (edited 01-27-2000).]

Mark Sreeves
Jan 26th, 2000, 05:25 PM
oh I forgot, to clear the list:


Private Sub Command2_Click()
ListView1.ListItems.Clear
End Sub


------------------
Mark Sreeves
Analyst Programmer

Mark.Sreeves@Softlab.co.uk
A BMW Group Company

Rodik
Jan 26th, 2000, 05:30 PM
Thank you Mark!

Just another q... how do you make that "code" style where you put code? :)

rancor
Jan 26th, 2000, 05:47 PM
I can't wite the code because it thinks I will put some code in the message but the info is avaible if you lock at the left field and read the "*UBB Code is ON". There is all commands that you can use..

------------------
Best Regards rancor
rancor@sajberhem.nu http://www.sajberhem.nu


[This message has been edited by rancor (edited 01-27-2000).]

[This message has been edited by rancor (edited 01-27-2000).]

Mark Sreeves
Jan 26th, 2000, 07:41 PM
take a look at http://www.vb-world.net/ubb/ubbcode.html


------------------
Mark Sreeves
Analyst Programmer

Mark.Sreeves@Softlab.co.uk
A BMW Group Company