简体   繁体   中英

How to remove the Cancel button from a save as dialog in vb.net?

I want to remove the Cancel button from a Save As Dialog Box, But by leafing through many subjects on the Internet? I still have no convincing results! Is it even possible?

I am developing an application, in vb.net.

Dim saveFileDialog1 As SaveFileDialog = New SaveFileDialog()
        saveFileDialog1.Filter = "Word Document (*.docx)|*.docx|Word 97-2003 Document (*.doc)|*.doc|Plain Text (*.txt)|*.txt"
        saveFileDialog1.FilterIndex = 1
        saveFileDialog1.RestoreDirectory = True
        saveFileDialog1.OverwritePrompt = True
        saveFileDialog1.FileName = System.IO.Path.GetFileName(files)

        If saveFileDialog1.ShowDialog() = DialogResult.OK Then

            auxFile = IO.Path.GetFileNameWithoutExtension(files) & ".docx"
            My.Computer.FileSystem.RenameFile(files, auxFile)

        ElseIf DialogResult.Cancel Then

            saveFileDialog1.FileName = ""

        End If
Using sfd As New SaveFileDialog
    'Configure sfd here.

    Do Until sfd.ShowDialog() = DialogResult.OK
    Loop

    'Use sfd.FileName here.
End Using

If you wanted to, you could display a message inside the loop to tell the user that they must select a file path. That will prevent them thinking that your app is broken if you haven't already made it clear that selecting a file path is mandatory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM