Locking current window

  • Thread starter Thread starter Joshua
  • Start date Start date
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
 
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
 
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
 
Back
Top