i have a form with a listbox. the listbox can be edited (things added/deleted) and when the form is closed i would like the items in the listbox to be saved when the red "x" in the top right corner is clicked

any ideas?

Recommended Answers

All 3 Replies

Use the FormClosing event.

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        '// save code here.
    End Sub

Try putting the save code in the Forms FormClosing Event.

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
   'Do Save stuff
  End Sub
commented: .did not down.vote .me to warn me. -3

Thanks for the down vote after I up voted yours> I will remember that for future posts I see of yours

Be a part of the DaniWeb community

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