user5503916
user5503916

Reputation:

How to prevent clicks outside the current form?

I want the form which will open when the user click a button, I don't want the user to click anywhere else outside this form(preventing him from clicking any other buttons on the parent form), I want to restrict his actions inside this form until he close it (For sure this form is top most), and I want the form to make alert(flicker) to any clicks outside it so the user will understand that he have to close it first.

Upvotes: 1

Views: 4430

Answers (2)

LiamT98
LiamT98

Reputation: 43

Super easy fix! I assume your code to show the form right now is

form.Show();

To create/show an instance of the form that is modal (restricts clicking to that form) all you need to change is that line to:

form.ShowDialog();

Liam

Upvotes: 3

drew
drew

Reputation: 1312

When opening the form instead of

Form form = new Form();
form.Show();

use

Form form = new Form();
form.ShowDialog()

Upvotes: 6

Related Questions