Fukkatsu
Fukkatsu

Reputation: 149

How to create Form On Top and cannot access other forms

Currently I have two forms(Form1 (base form) and Form2), from form1 I open form2, I want form1 to be inaccessible (unable to click buttons and access any other objects on that form) while form 2 is still open, and once form2 is closed I can access form1 again, I don't know what this behavior is called

I know how to put the form always on top via newForm.TopMost = true and how to check if a form is open via Application.OpenForms.OfType<Alert_Form>().Any(), Anyone know the sniplet I need to achieve what I want for form1 and possible (any other form)

Thanks and cheers

Upvotes: 0

Views: 274

Answers (1)

jmcilhinney
jmcilhinney

Reputation: 54417

You simply call ShowDialog on your Form2 instance rather than Show. That will display a modal dialogue, which is the behaviour that you describe.

Upvotes: 4

Related Questions