When my app starts the OpenFileDialog is displayed, and the user selects a file.
After the filename is captured, my code tells the OpenFileDialog to display again so the user will select a second file, at which time I capture the second filename.
However, when the OpenFileDialog is invoked the second time, it does not display. If I press Alt->Tab (in Windows Vista or XP) the dialog shows up, so it is working in a sense, but it isn't showing up on my screen unless I Alt->Tab.
How can I get the dialog to show up the second time automatically after the dialog disappears the first time?
I have tried creating a new dialog, adding a second form with its own dialog, along with various form and dialog refresh, dispose, show commands - nothing seems to work. I've posted the latest iteration of my code below. Thanks for any help!
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cd1 As New System.Windows.Forms.OpenFileDialog
With cd1
.Title = "Select 'D' File"
.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
.Filter = "*_D*.txt|*_D*.txt"
.ShowDialog()
sFileName1 = .FileName
End With
With cd1
.Title = "Select 'PI' File"
.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
.Filter = "*_PI*.txt|*_PI*.txt"
.ShowDialog()
sFileName2 = .FileName
End With
End Sub
After the filename is captured, my code tells the OpenFileDialog to display again so the user will select a second file, at which time I capture the second filename.
However, when the OpenFileDialog is invoked the second time, it does not display. If I press Alt->Tab (in Windows Vista or XP) the dialog shows up, so it is working in a sense, but it isn't showing up on my screen unless I Alt->Tab.
How can I get the dialog to show up the second time automatically after the dialog disappears the first time?
I have tried creating a new dialog, adding a second form with its own dialog, along with various form and dialog refresh, dispose, show commands - nothing seems to work. I've posted the latest iteration of my code below. Thanks for any help!
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cd1 As New System.Windows.Forms.OpenFileDialog
With cd1
.Title = "Select 'D' File"
.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
.Filter = "*_D*.txt|*_D*.txt"
.ShowDialog()
sFileName1 = .FileName
End With
With cd1
.Title = "Select 'PI' File"
.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
.Filter = "*_PI*.txt|*_PI*.txt"
.ShowDialog()
sFileName2 = .FileName
End With
End Sub