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

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.

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.

.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

"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

commented: "confuse a lot of users", it's what i love about replying to certain threads, Not.:) +12

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.

>>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

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

>>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.

Oh okay, i'll try it now

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

commented: .insuficient details in post. -3

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.:)

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. :/

.hmm.
If you can, attach the project in a .zip file.

somehow, when i tried the code the Class List Form is not showing anymore :/

>>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 ;)

how to refresh list view in vb.net after adding or updating data in data base

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.