Results 1 to 3 of 3

Thread: [RESOLVED] Fill a Listview with info from .txt file

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2009
    Posts
    10

    Resolved [RESOLVED] Fill a Listview with info from .txt file

    Hi,

    In a mobile application I need to read from a .txt file and fill with information a ListView Control. I don't know why a receive an error.

    The code is below:

    Dim StreamReader As IO.StreamReader
    Dim line As String
    StreamReader = New IO.StreamReader("Smart Card\fisier.txt")

    While StreamReader.Peek <> -1
    line = StreamReader.ReadLine()
    ListView1.Items.Add(line)
    End While


    The error message is in "ListView1.Items.Add(line)"; "Error 1 Value of type 'String' cannot be converted to 'System.Windows.Forms.ListViewItem'.

    The .txt file contain first name and given name separated by a space and I want to display the list of names in a ListView Control.

    Can anybody help me?

    Thank you,
    Robert

  2. #2
    Frenzied Member
    Join Date
    Oct 2005
    Posts
    1,286

    Re: Fill a Listview with info from .txt file

    You need to add a listview item to a listview.After
    line = StreamReader.ReadLine()
    try
    Dim lvItem as new listviewitem
    lvitem.text = line
    listview1.items.add (lvitem)


    That should do it - although I haven't checked the code in Visual Studio
    Pete Vickers
    MVP - Device Application Development
    http://www.gui-innovations.com http://mobileworld.appamundi.com/blogs/

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2009
    Posts
    10

    [RESOLVED]Re: Fill a Listview with info from .txt file

    Thank you a lot.

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