CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2001
    Posts
    51

    adding items tolistview

    Can't figure out why this don't work. Have looked at examples and still having problem. Here's the code:
    Getting error "Type Mismatch"

    private Sub AddFileToListView(strFileName as string, FileDate as date)
    Dim li as ListItem

    set li = ListView1.ListItems.Add(, , strFileName)

    With li
    .SubItems(1) = strFileName
    .SubItems(2) = FileDate
    End With

    End Sub



    I get a file name listed for strFileName, however, I can't get the FileDate to be listed. Any suggestions?


  2. #2

    Re: adding items tolistview

    have U add columns with listview form page?
    at design time, right button on listview and choose property.

    <center>
    <HR width=80%>
    <img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
    </center>

  3. #3

    Re: adding items tolistview

    set view property = 3 'report

    <center>
    <HR width=80%>
    <img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
    </center>

  4. #4
    Join Date
    Apr 2001
    Posts
    36

    Re: adding items tolistview

    Yes at design times colums are set
    column 1 = File Name
    column 2 = File Date


  5. #5
    Join Date
    Apr 2001
    Posts
    36

    Re: adding items tolistview

    Did not work. Now I got it to list the file name in the column "File Name" and also the file name is listed in column "File Date"

    private Sub AddFileToListView(strFileName as string, FileDate as date)
    Dim li as ListItem
    Lv1.View = lvwReport
    set li = Lv1.ListItems.Add(, , strFileName)
    With li
    .SubItems(1) = strFileName
    .SubItems(2) = FileDate 'get error HERE NOW' "error says "Invalid property value"
    End With
    set li = nothing
    End Sub





    If I add "on error resume next" I get the file name in the column "File Date".

    Any reason why?


  6. #6
    Join Date
    Apr 2001
    Posts
    36

    Re: adding items tolistview

    Found solution

    set li = Lv1.ListItems.Add(, , strFileName) 'This is .SubItems(0)
    With li
    .SubItems(1) = FileDate
    End With
    set li = nothing





  7. #7

    Re: adding items tolistview

    yeah!


    <center>
    <HR width=80%>
    <img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
    </center>

  8. #8

    Re: adding items tolistview

    U cabn access to item of lisitem for key...
    so U have no link to position..

    .SubItems("FileName") = strFileName
    .SubItems("FileDate") = FileDate

    <center>
    <HR width=80%>
    <img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
    </center>

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

Featured