Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Working with ShowDialog and Show Function of window form in .net 2.0.

Author: Zunnair
Download Source Code : 826_ShowNShowDialogApp.zip

In this simple article you will learn that how you can work with show and showdialog function.

 ShowDialog Method:

Showdialog method used when you want to show form as Modal form, mean user can not click on any other form without closing this form.

 

Show Method:

Show method used when you want to show form as Modeless form, mean user can click on any other form without closing this form.

 

 

Create new c# project and add new Form with name Form2.

 

Now write code on Form Load Event

 

C#

 

private void Form1_Load(object sender, EventArgs e)

        {

            this.Text = "ShowDialog and Show Difference";

            button1.Text = "Show Dialog";

            button2.Text = "Show";

        }

 

VB

 

Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)

        Me.Text = "ShowDialog and Show Difference"

        button1.Text = "Show Dialog"

        button2.Text = "Show"

    End Sub

 

Now write code on button click event

 

C#

 

private void button1_Click(object sender, EventArgs e)

        {

            Form2 frm = new Form2();

            frm.ShowDialog();

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

            Form2 frm = new Form2();

            frm.Show();

        }

 

VB

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim frm As New Form2()

        frm.ShowDialog()

    End Sub

 

    Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)

        Dim frm As New Form2()

        frm.Show()

    End Sub

 

This is simple code for this.

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Writing Getter setter methods of class using C# in .net 2.0

Disclaimer - Privacy
© 2002-2017 DevASP.net