vb.netvisual-studiosavefiledialogcancel-button

VB SaveFileDialog if cancel then


When the user presses the "Cancel" button in SaveFileDialog I want to rename a textlabel.

Private Sub SaveFileDialog1_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk
    Label6.Text = "Saved!"
End sub

This is working for the "Save" Button. I don't know how to do it for the "Cancel" button.

Thanks


Solution

  • Instead of using that event, why not compare the result returned from the ShowDialog() method?

    If SaveFileDialog1.ShowDialog() = DialogResult.Ok
        Label6.Text = "Saved!"
    Else
        Label6.Text = "Cancelled!"
    End If