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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check if form is modal? 1

Status
Not open for further replies.

gny

Programmer
Jun 3, 2001
116
SE
Hi!
After my form has been opened I need to check whether or not it was opened using Show() or ShowDialog().

Does anyone know if this can be checked using a built-in property or if I have to shadow ShowDialog() and remember myself that the form is modal, as in:
Code:
public shadows sub ShowDialog()
   _IsModal = True
   MyBase.ShowDialog()
end sub

Thanks.
 
Silly me, I missed the Form.Modal property which does the trick....
 
ERr.. what's the difference between these ".show()" and ".showdialog()" ?
 
.Show will open the form and the code in the calling sub will continue executing and the user can interact with the parent form.

.ShowDialog will open the form and halt the code in the calling sub and prevent the user from interacting with the parent form until the dialog form is closed.

This of a print dialog, or file save/open dialog, or a message box. You can't interact with the parent form until that dialog form closes.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
An easy way to see the difference in behavior:

Sample #1: .Show
Code:
dim f as form
f.show
msgbox("Form Opened!")

Sample #2: .ShowDialog
Code:
dim f as form
f.showdialog
msgbox("Form Closed!")

In the first sample, as soon as the form begins loading, a message box will appear.

In the second sample, the message box won't appear until the form is closed.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top