We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,756 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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

4
Contributors
16
Replies
1 Year
Discussion Span
1 Month Ago
Last Updated
22
Views
aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 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
Carpe per diem
Moderator
3,592 posts since Aug 2010
Reputation Points: 561
Solved Threads: 445
Skill Endorsements: 32

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
Skill Endorsements: 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
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8

"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
Carpe per diem
Moderator
3,592 posts since Aug 2010
Reputation Points: 561
Solved Threads: 445
Skill Endorsements: 32

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
Skill Endorsements: 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
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8

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
Skill Endorsements: 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
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8

Oh okay, i'll try it now

aishapot
Junior Poster in Training
75 posts since Sep 2011
Reputation Points: 7
Solved Threads: 0
Skill Endorsements: 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
Skill Endorsements: 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
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8

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
Skill Endorsements: 0

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

codeorder
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8

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
Skill Endorsements: 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
Skill Endorsements: 0

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

shah unnati
Newbie Poster
1 post since Mar 2013
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.1313 seconds using 2.82MB