Login or Sign Up to become a member!
LessThanDot Sit Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot friendfeed Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

VB.Net: Open a form as modal

From Wiki

Jump to: navigation, search

You can open a dialog as modal (from MSDN: 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.) by using Show dialog

Image:Formshowdialog.jpg

  1. Public Class Form1
  2.  
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         Dim _frm2 As New Form2
  5.         _frm2.ShowDialog()
  6.     End Sub
  7. End Class

You can also do this

  1. Public Class Form1
  2.  
  3.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  4.         Dim _frm2 As New Form2
  5.         _frm2.ShowDialog(me)
  6.     End Sub
  7. End Class

This means that the parentform property will be set on the modal form so that you can easily refer to the parent if needed. For the rest it will just do the same thing.

524 Rating: 3.1/5 (8 votes cast)