Results 1 to 6 of 6

Thread: Listview Contol, populating first column

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2010
    Posts
    1,462

    Listview Contol, populating first column

    Code:
        Dim i As Integer, theListView As ListItem
        LV2.ColumnHeaders.Clear
        LV2.ColumnHeaders.Add , , "Hdr1", 1000
        LV2.ColumnHeaders.Add , , "Hdr2", 1000
        LV2.ColumnHeaders.Add , , "Hdr3", 1000
        LV2.ColumnHeaders.Add , , "Hdr4", 1000
       
        LV2.View = lvwReport
        LV2.Gridlines = True
     
            For i = 1 To 10
                Set theListView = Form3.LV2.ListItems.Add
                    theListView.SubItems(1) = "Row1"
                    theListView.SubItems(2) = "Row2"
                    theListView.SubItems(3) = "Row3"
                   ' theListView.SubItems(4) = "Row4"
            Next
    Although I get 4 headers I cannot populate 4 columns. Both .SubItems(0) and (4) give errors if attempted.
    How can I put text in column 1 ?
    Last edited by AlexanderBB; Feb 19th, 2018 at 11:57 PM.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Listview Contol, populating first column

    The SubItems are sidecars dangling off the actual item. The "first column" is the actual item, so you assign it Text there (on the Add method call).

    Crack the Fine Manual open. It is chock full of answers to such simple questions. Reading is FUNdamental to programming.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2010
    Posts
    1,462

    Re: Listview Contol, populating first column

    Thanks
    Last edited by AlexanderBB; Feb 20th, 2018 at 02:50 AM.

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Listview Contol, populating first column

    I often make that first column very skinny and ignore it for that very reason.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Listview Contol, populating first column


  6. #6
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: Listview Contol, populating first column

    Hey, I suppose I just really like the KISS principle ... you know that most elegant and parsimonious of solutions, like that E-mc2 thing. It seems the rare case that a report formatted ListView would have only one column. Therefore, I've always been a bit confused that they did it the way they did it anyway. So, I give it a KISS and skip the first column.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

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