Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close openfiledialog control

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
When I click on the open button in an openfiledialog control in VB 2005 the control window stays on the screen until the entire sub routine is completed. How can I get it to hide when I click on open?

Thank you.
 
The dialog is supposed to unload itself when it is finished. What you are seeing is likely an "afterimage" of the dialog that is staying on the screen because the subsequent code is cpu-intensive and is preventing the screen from refreshing. Try putting an Application.DoEvents after the OpenFileDialog.ShowDialog call.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
I tried adding the application.doevents to the code like this:

opnChartIPTVCumChart.InitialDirectory = "C:\Program Files\Quality Database\Data Transfer"
opnChartIPTVCumChart.DefaultExt = "xls"
opnChartIPTVCumChart.FileName = ""
opnChartIPTVCumChart.ShowDialog()
xlApp.DoEvents()

The program runs fine, however at the end I get this error:

Public member 'DoEvents' on type 'ApplicationClass' not found.

I am using an instance of Excel to add charts to a new file. Since there are a lot of commannds the openfiledialog seems to stay there for a while.

Any other suggestions?
 
DoEvents is a member of the System.Windows.Forms.Application class. try using it like this:

System.Windows.Forms.Application.DoEvents



I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Why not just unload it after you are done?

Code:
Dim comDialog as New OpenFileDialog
If comDialog.ShowDialog = DialogResult.Ok Then
'etc, etc
End If
comDialog.Dispose
comDialog = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top