Locking current window

J

Joshua

Hello,

I want to be able to prevent the user from working on any
window/form but the currently active window/form.

Only when "cancel" or "submit" is pressed can the user
click any other area of the screen and actually gain focus.

Is there any simple window property for this?

Thank you,

Josh
 
B

Bo Ching

You can ShowDialog method to show the child form but you have to implement
you child form as a diaglog box and use the result of the dialog box on the
parent.

On the child form set this properties:
btnCancel.DialogResult = DialogResult.Cancel;

btnSelect.DialogResult = DialogResult.OK;

CancelButton = btnCancel;

AcceptButton = btnSelect;

On the parent form:
//open a child form
Childfrom cf = new Childform();

if (cf.ShowDialog(this) == DialogResult.Cancel)

{

do your cancel implementation

}

else

{

do you ok implementation

}

//close your child form

fc.Dispose();



hope this help

Bo Ching
 
H

Herfried K. Wagner

Hello,

Joshua said:
I want to be able to prevent the user from working on any
window/form but the currently active window/form.

Use ShowDialog instead of Show for showing the form.

Regards,
Herfried K. Wagner
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top