Differences between Show and ShowDialog methods?

 Posted by Ddd on 1/31/2011 | Category: C# Interview questions | Views: 12622 | Points: 40

These methods are used in Window applications to call one form from another

example: we have Form1 and we want to call Form2.

we may write like this in Form1

private void button1_Click(object s, EventArgs e)
Form2 f=new Form2();


we can also write f.ShowDialog();

The difference:

Show method does not make the target form (Form2 in this case) as a modal dialog

box. ShowDialog() will make Form2() as a modal dialog box. So, when we use

ShowDialog() method, we cannot click anywhere on Form1 unless we close the

instance of Form2. In case of Show, we can click on Form1 even when Form2 is open.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response