1. Create a new form in your project and set it as the
startup form.
2. Add a second form that can be used as dialog.
3. Add a button to the dialog form and then do the following:
When the application starts, the startup form should
call the dialog form to be shown on the screen.
During this, the startup form has to be disabled for a while.
The second form has a button and if you click it, it should
enable the first form and close the dialog.
When a form is displayed modally, no input (keyboard or mouse click) can occur except to objects on the modal form. The program must hide or close a modal form (usually in response to some user action) before input to another form can occur. Forms that are displayed modally are typically used as dialog boxes in an application.
You can use this property to determine whether a form that you have obtained from a method or property has been displayed modally.
To display a form modally use the ShowDialog method
Example
The following example displays a form as a modal dialog box and reads the result of the dialog box before determining whether to read the value of a TextBox control on the dialog box form. This example assumes that a Form named Form2 is created and that it contains a TextBox control named TextBox1. The example uses the version of ShowDialog that specifies an owner for the dialog box.
Note This example shows how to use one of the overloaded versions of ShowDialog. For other examples that might be available, see the individual overload topics.
Code:
Public Sub ShowMyDialogBox()
Dim testDialog As New Form2()
' Show testDialog as a modal dialog and determine if DialogResult = OK.
If testDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK Then
' Read the contents of testDialog's TextBox.
result.Text = testDialog.TextBox1.Text
Else
result.Text = "Cancelled"
End If
testDialog.Dispose()
End Sub 'ShowMyDialogBox