how do i add column headings to my listview control??
i have never used this control before and would like to
view and edit data from my sql database in the listview control
please help me i have tried all sorts of ways and cannot get it to work!!
Printable View
how do i add column headings to my listview control??
i have never used this control before and would like to
view and edit data from my sql database in the listview control
please help me i have tried all sorts of ways and cannot get it to work!!
goes like this:
Code:'add columnHeaders..the width of the columns is
'the width of the ctrl / 2 by the num of headers
'
Set sColumn = Listview1.ColumnHeaders.Add(, , "Name")
Set sColumn = Listview1.ColumnHeaders.Add(, , "Phone #1")
Set sColumn = Listview1.ColumnHeaders.Add(, , "Phone #2")
'
'add some data to the listitem (sItem)
Set sItem = Listview1.ListItems.Add(, , "Kim & Deb", 1, 1)
sItem.SubItems(1) = "905-799-9415"
sItem.SubItems(2) = "who knows"
' Create an object variable for the ColumnHeader object.
Dim clmX As ColumnHeader
' Add ColumnHeaders.
Set clmX = lvFind.ColumnHeaders.Add(, , "Product", (lvFind.Width - 1066) / 2)
Set clmX = lvFind.ColumnHeaders.Add(, , "Supplier ID", (lvFind.Width - 1066) / 2)
Set clmX = lvFind.ColumnHeaders.Add(, , "Category ID", 976)
i have tried both of your codes but cannot see my column headings
i know there is a property that you can select if you dont want to see the headings but
my property is set to false so you can
all i see is my control no headings????
help please
Paste this code..You will see headers.I fogot a line or
two in my first post.
Code:Option Explicit
Private Sub Form_Load()
'creat obj var for columnHeader obj and listitem obj
Dim sColumn As ColumnHeader
Dim sItem As ListItem
'
'start in report view
ListView1.View = lvwReport
'
'set the size and pos of the listview
'
ListView1.Width = ScaleWidth
ListView1.Height = ScaleHeight
ListView1.Top = ScaleTop
ListView1.Left = ScaleLeft
'
'
'add columnHeaders..the width of the columns is
'the widht of the ctrl / 2 by the num of headers
'
Set sColumn = ListView1.ColumnHeaders.Add(, , "Name")
Set sColumn = ListView1.ColumnHeaders.Add(, , "Phone #1")
Set sColumn = ListView1.ColumnHeaders.Add(, , "Phone #2")
'
'
'
End Sub
one more thing i want to display and edit data from My sql in the different headings you gave me
how would i do this??
thankyou for all your help
'add some data to the listitem (sItem)
Set sItem = Listview1.ListItems.Add(, , "Kim & Deb", 1, 1)
sItem.SubItems(1) = "905-799-7777"
sItem.SubItems(2) = "who knows where they live"
replace the " " fields with your variables or rs!fieldname
Set sItem = Listview1.ListItems.Add(, , data1.recordset!myField,1, 1)
or
Dim x as string
x = data1.recordset!field
Set sItem = Listview1.ListItems.Add(, , x, 1, 1)
Hope this helps...I have to go..going fishing at 4 AM.
If it doesn't drop me an email and if I get time tomorrow night I'll see if I can be of a little more help...
I'm on vacation so I can't guarantee I'll be around.
Later,
Wayne