Results 1 to 7 of 7

Thread: help me please with.............

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    103

    Angry

    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!!

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    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"
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    ' 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)

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    103

    Angry i have tired but it does not work

    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

  5. #5
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    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
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2000
    Posts
    103

    Talking that worked great!!

    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

  7. #7
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    '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


    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width