【问题标题】:How to remove the Cancel button from a save as dialog in vb.net?如何从 vb.net 中的另存为对话框中删除取消按钮?
【发布时间】:2021-03-27 00:52:38
【问题描述】:

我想从另存为对话框中删除取消按钮!但是在网上翻了很多题目,还是没有令人信服的结果!有没有可能?

我正在开发一个应用程序,在 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

【问题讨论】:

  • 如果需要选择文件路径,您可以简单地循环显示对话框,直到用户选择文件路径。

标签: vb.net button dialog


【解决方案1】:
Using sfd As New SaveFileDialog
    'Configure sfd here.

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

    'Use sfd.FileName here.
End Using

如果您愿意,您可以在循环内显示一条消息,告诉用户他们必须选择文件路径。如果您尚未明确说明选择文件路径是强制性的,这将防止他们认为您的应用已损坏。

【讨论】:

  • 非常感谢jmcilhinney,我将实现foruni代码,再次感谢您:) Claude.
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-13
  • 2013-06-23
  • 2012-10-24
  • 1970-01-01
  • 1970-01-01
  • 2012-11-05
  • 1970-01-01
相关资源
最近更新 更多