[Help]Saving ListView[Solved]

Posts 1–15 of 20 · Page 1 of 2
[Help]Saving ListView[Solved]
Im making a program its like a database but without it xD

Its too save all my emails passwords logins etc..
I think is needed 2 save the config and load it when it opens...Idk.
And i want like ..ever i enter in the program the listview items and etc, auto load..
@Jason , @Hassan & @NextGen1 @Blubb1337i need u xD
Too bad I'm not in the list, I cannot help you then =D.
Add Kevin, or I won't help
Done, But who is kevin ? XDDD
Quote Originally Posted by Lyoto Machida View Post
Done, But who is kevin ? XDDD
<<< -.-"

[highlight="vb"] Dim File As String = "content.txt"
Dim Delimiter As Char = "|"

Private Sub SaveListview()
Dim full As String = ""

For i = 0 To ListView1.Items.Count - 1
full = ListView1.Items(i).Text & Delimiter & ListView1.Items(i).SubItems(0).Text & vbNewLine
Next

Using sWrite As New IO.StreamWriter(File)
sWrite.Write(full)
End Using
End Sub

Private Sub GetContent()
If IO.File.Exists(File) Then
Using sRead As New IO.StreamReader(File)
While Not sRead.EndOfStream
Dim splitted() As String = Split(sRead.ReadLine, Delimiter)
ListView1.Items.Add(splitted(0))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(splitted(1))
End While
End Using
End If
End Sub[/Highlight]

Feel free to modify...
Quote Originally Posted by Blubb1337 View Post
<<< -.-"

[highlight="vb"] Dim File As String = "content.txt"
Dim Delimiter As Char = "|"

Private Sub SaveListview()
Dim full As String = ""

For i = 0 To ListView1.Items.Count - 1
full = ListView1.Items(i).Text & Delimiter & ListView1.Items(i).SubItems(0).Text & vbNewLine
Next

Using sWrite As New IO.StreamWriter(File)
sWrite.Write(full)
End Using
End Sub

Private Sub GetContent()
If IO.File.Exists(File) Then
Using sRead As New IO.StreamReader(File)
While Not sRead.EndOfStream
Dim splitted() As String = Split(sRead.ReadLine, Delimiter)
ListView1.Items.Add(splitted(0))
ListView1.Items(ListView1.Items.Count - 1).SubItems.Add(splitted(1))
End While
End Using
End If
End Sub[/Highlight]

Feel free to modify...
Im gonna try it now and come back to say what happened :P

Now i know you're kevin xDDD



Edit: @Blubb1337 Your code is good and worked, NOw i just want to know how i add a item in another column please
Okay, report back then.

Edit: @Blubb1337 Your code is good and worked, NOw i just want to know how i add a item in
another column please
Let's imagine 3 Columns.

Column 1 = Mainitem
Column 2 = Subitem #0
Column 3 = Subitem #1

[highlight="vb"]Listview1.items.add("Main item")
listview1.items(listview1.items.count - 1).subitems.add("First subitem - column 2")
listview1.items(listview1.items.count - 1).subitems.add("Second subitem - column 3")[/highlight]
Quote Originally Posted by Blubb1337 View Post
Okay, report back then.



Let's imagine 3 Columns.

Column 1 = Mainitem
Column 2 = Subitem #0
Column 3 = Subitem #1

[highlight="vb"]Listview1.items.add("Main item")
listview1.items(listview1.items.count - 1).subitems.add("First subitem - column 2")
listview1.items(listview1.items.count - 1).subitems.add("Second subitem - column 3")[/highlight]
That i know..But the problem is..I want just to add 1 item to 1 column..
I dont want to all columns (That 3)...
Quote Originally Posted by Lyoto Machida View Post


That i know..But the problem is..I want just to add 1 item to 1 column..
I dont want to all columns (That 3)...
Do you only have 1 column

[highlight="vb"]Listview1.items.add("Text")[/highlight]

or do you have multiple columns and the first column is already filled and you want to edit the selected subcolumn?

[highlight="vb"]If listview1.selecteditems.count <> 0 then
listview1.selecteditems(0).subitems(0).text = "Bla" 'edit first column on selected item
end if[/highlight]

Please explain it more deeply...
Quote Originally Posted by Blubb1337 View Post
Do you only have 1 column

[highlight="vb"]Listview1.items.add("Text")[/highlight]

or do you have multiple columns and the first column is already filled and you want to edit the selected subcolumn?

[highlight="vb"]If listview1.selecteditems.count <> 0 then
listview1.selecteditems(0).subitems(0).text = "Bla" 'edit first column on selected item
end if[/highlight]

Please explain it more deeply...
lol Kevin i learned new things with you XD

But what im trying to say is: I already have the first and second column..
But i want to add the 3º separated (If you can explain me that..Thanks =))..

IF is 2 hard or something i got a new idea..


@NextGen1 lol Thanks for the lesson xD
Quote Originally Posted by Lyoto Machida View Post


lol Kevin i learned new things with you XD

But what im trying to say is: I already have the first and second column..
But i want to add the 3º separated (If you can explain me that..Thanks =))..

IF is 2 hard or something i got a new idea..


@NextGen1 lol Thanks for the lesson xD
[highlight="vb"]listview1.items(listview1.items.count - 1).subitems(1).text = "I guess I got it"[/highlight]

[highlight="vb"]listview1.items(0).subitems(1).text = "I guess I got it" 'edit 3rd column of 1st item in listview[/highlight]

???
See why you should have added kevin in the first place?

Lesson learned.
Testing, Editing this soon..

First code error: InvalidArgument=Value of '-1' is not valid for 'index'.
Parameter name: index

Second code error: InvalidArgument=Value of '0' is not valid for 'index'.
Parameter name: index





Quote Originally Posted by Lyoto Machida View Post
Testing, Editing this soon..

First code error: InvalidArgument=Value of '-1' is not valid for 'index'.
Parameter name: index

Second code error: InvalidArgument=Value of '0' is not valid for 'index'.
Parameter name: index

Does your listview even contain any item?

If you are trying to edit the 3rd column without having an item added that won't work.

If you actually did that. First add an empty item like.

[highlight="vb"]Listview1.items.add("")[/highlight]
Quote Originally Posted by Blubb1337 View Post
Does your listview even contains any item?

If you are trying to edit the 3rd column without having an item added that won't work.

If you actually did that. First add an empty item like.

[highlight="vb"]Listview1.items.add("")[/highlight]
Ok, So i will do the other way what u said...

Im gonna do a form with this:

Code:
Form1.ListView1.Items.Add(login.Text)
        Form1.ListView1.Items(Form1.ListView1.Items.Count - 1).SubItems.Add(email.Text)
        Form1.ListView1.Items(Form1.ListView1.Items.Count - 1).SubItems.Add(password.Text)
        Form1.ListView1.Items(Form1.ListView1.Items.Count - 1).SubItems.Add(website.Text)
And i think is working...
PS: I edited your subs bcuz of a problem but now is solved =)

Solved =)

Thank you blubb!
Posts 1–15 of 20 · Page 1 of 2
This thread is closed for replies.

Tags for this Thread

None

Talk with us