Results 1 to 4 of 4

Thread: [RESOLVED] loading listview

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    193

    Resolved [RESOLVED] loading listview

    This is so frustrating, I must be missing something too simple. But I have been on this for hours and cannot load a simple listview... I have just migrated to .Net so it is a little different... THis is what I have and nothing is showing, not even the column headers..... I know there is data there...
    Please help.. Thanks so much

    ST_ind = pFeature.Fields.FindField(ST_ID)
    Offset_ind = pFeature.Fields.FindField(OFFSET)
    lsvStations.View = View.Details
    lsvStations.Columns.Add("Station ID", 100, HorizontalAlignment.Left)
    lsvStations.Columns.Add("Offset", 200, HorizontalAlignment.Left)


    lsvStations.Clear()
    Do While Not (pFeature Is Nothing)

    Dim SSItem1 As New ListViewItem(pFeature.Value(ST_ind).ToString())
    SSItem1.SubItems.Add(pFeature.Value(ST_ind).ToString())
    SSItem1.SubItems.Add(pFeature.Value(Offset_ind).ToString())
    lsvStations.Items.AddRange(New ListViewItem() {SSItem1})


    pFeature = pFCursor.NextFeature
    Loop

  2. #2
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Lancashire UK
    Posts
    375

    Re: loading listview

    Well to get your column headers to show you need to set the view mode to details.

    vb Code:
    1. ListView1.View = View.Details

    Have you set a breakpoint at the start of the loop to see if it actually steps into the loop or just jumps past it ?

    EDIT: just noticed in your code that you've done the details property.
    When you call 'clear()' you are removing the column headers, this is why no headers are showing.
    Call the items.clear() method instead this will clear the items but leave the headers alone...
    Last edited by Tinbeard; Mar 31st, 2007 at 09:55 AM.
    If my post helps , please feel free to rate it

  3. #3
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: loading listview

    Yeah Tinbeard is right, calling ListView.Clear() removes the items AND columns. Youd want to use ListView1.Items.Clear()
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 2003
    Posts
    193

    Re: loading listview

    Thanks, that did it.. I guess the clear was in the wrong place, that was all I had to change..
    Thanks again

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