how to refresh listview in vb.net
Hello, I have a listview wherein when I double click a student another form pops up where i edit the student info. When i click on cancel it goes back to the menu and when i click on the reports i want it to be able to refresh so that i wont have to close the program again. Thank you for your help.
Much appreciated! :D
aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
You double click on an entry (a student) in a listview. This brings up an edit form. If you click on cancel (which is what you stated), typically the response is to discard the changes in the edit form so hitting refresh would be pointless as there are no changes.
When you say you go back to the menu do you mean the form that you were in when you double clicked on the student? What do you mean by "when I click on the reports"? And what do you want to refresh? We can't see your form(s) or your code so you'll have to be more specific.
Reverend Jim
Posting Shark
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159
I meant that when i clicked on cancel i finished editing and i want the listview to view the changes that i made on the edit form. But i what i have to do is to close the program and view the class list again to make sure that it is really edited.
aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
.see If this helps.
Public Class Form1
Private Sub ListView1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListView1.SelectedIndexChanged
With ListView1
If Not .SelectedItems.Count = 0 Then
With .SelectedItems(0) '// first selected.item.
Form2.TextBox1.Text = .Text
Form2.TextBox2.Text = .SubItems(1).Text
Form2.ShowDialog()
End With
End If
End With
End Sub
End Class
Public Class Form2
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
With Form1.ListView1
If Not .SelectedItems.Count = 0 Then
With .SelectedItems(0) '// first selected.item.
.Text = TextBox1.Text
.SubItems(1).Text = TextBox2.Text
Me.Close()
End With
End If
End With
End Sub
End Class
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
"Cancel" is universally regarded as "throw out what I did". Have a look at codeorder's code above. He's doing substance so I might as well do style. I suggest you relabel your button to something like "OK" or "COMMIT" instead of "Cancel" or you are going to confuse a lot of users.
OK - I'm happy with my changes. Please save them and continue
CANCEL - throw away my changes and continue
Reverend Jim
Posting Shark
1,167 posts since Aug 2010
Reputation Points: 253
Solved Threads: 159
The cancel button is for exit. like, the listview have the records right, when the user double clicks the student in the listview, a new form will show, having the buttons, EDIT STUDENT and CANCEL so the cancel is just for the exit or like going back to menu, thinking about it, i think i should just change it CANCEL to BACK TO MENU.
Anyway, i'll try the code.
aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
>>Anyway, i'll try the code.
If you're gonna try someone, don't try .Me cause I'll knock more than teeth out of a pillow. :D
.sorry, morning here, no coffee yet.:(
"code".order
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
What is this code for, what is the Form2 is that the list of class or the edit students information form?
Form2.TextBox1.Text = .Text
Form2.TextBox2.Text = .SubItems(1).Text
aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
>>I have a listview wherein when I double click a student another form pops up where i edit the student info.
ListView for all.Students on Form1, TextBoxes for .Edit .SelectedStudent.Info on Form2.
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
shoot, the form for the list of class is not opening, there's no error it's just not opening, it's taking too long
aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
Then, AndAlso, read your rep.comment.
Hope it helps to get you a solution quicker, and not waste the world's time w/nonsense.
Nothing personal, might help others in the future as well.:)
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
i don't know what happened but when i tried the code, whenever i click on the class list on the menu bar it's not opening. :/
aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
.hmm.
If you can, attach the project in a .zip file.
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
somehow, when i tried the code the Class List Form is not showing anymore :/
aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
>>Anyway, i'll try the code.
If you're gonna try someone, don't try .Me cause I'll knock more than teeth out of a pillow. :D
.sorry, morning here, no coffee yet.:(
"code".order
Lol :P ;)
aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0