Hi
I amd trying to populate a listview control from a text file.
Text File has data set as:
Line 1 = Name
Line 2 = Date
Line 3 = email address
eg:
Iam trying to use this code
The code works fine if iam only adding 1 subitemCode:'POPULATE LISTVIEW WITH TEXTFILE 'http://www.vbforums.com/showthread.php?t=242250&highlight=write+listview+textfile Dim sr As IO.StreamReader Dim strLine, strLine2, strLine3 As String Dim strFileName As String = Application.StartupPath & "\Emailed.txt" ' Open the file to read. Try sr = IO.File.OpenText(strFileName) Try With Me.lsvEmailed While sr.Peek <> -1 strLine = sr.ReadLine strLine2 = sr.ReadLine strLine3 = sr.ReadLine lsvEmailed.Items.Add(strLine).SubItems.Add(strLine2).Subitems.Add(strLine3) End While End With Catch MsgBox("Unexpected error reading character file - check the contents of " _ + strFileName + ".", MsgBoxStyle.Exclamation) End Try sr.Close() Catch ex As Exception MessageBox.Show(ex.Message, "Error opening file!") End Try
but if i try to add 2 subitemsCode:lsvEmailed.Items.Add(strLine).SubItems.Add(strLine2)
When i build the file i get a build error:Code:lsvEmailed.Items.Add(strLine).SubItems.Add(strLine2).Subitems.Add(strLine3)
Any help much appreciatedError 2 'Subitems' is not a member of 'System.Windows.Forms.ListViewItem.ListViewSubItem'. C:\Documents and Settings\Toecutter\My Documents\Visual Studio 2005\Projects\Emailed\Emailed\Form1.vb 201 25 Emailed
Toe
ps i have attached this to this thread
http://www.vbforums.com/showthread.php?t=242250





Reply With Quote
