Disable or hide the form close button

It is possible to hide or disable the "X" at the top right of a windows form?

I have an addin that pops up a form. I don't want the user to be able to close the form without completing the form.

 

I tried:

 

e.Cancel = True

 

in the forms closing procedure, but it doesn't prevent the form from closing.

 

Thanks in advance,

Mike

 

 

Posted by: Michael Frayser
Post date: 11/9/2005 10:05:41 AM

6 REPLIES

RE: Disable or hide the form close button

Mike,

 

Try this.

 

Posted by: Jason Newell
Post date: 11/9/2005 10:11:02 AM

RE: Disable or hide the form close button

Posted By Jason Newell on 11/9/2005 4:11:02 PM

Mike,

 

Try this.

 

 

 

Okay, that sorta worked. Now how do I hide the close button at the bottom left of the form?

 

Posted by: Michael Frayser
Post date: 11/10/2005 12:09:49 AM

RE: Disable or hide the form close button

Sorry Mike, I don't understand what you're asking on this one . Can you be a little more specific?

 

Posted by: Jason Newell
Post date: 11/10/2005 5:51:10 AM

RE: Disable or hide the form close button

I want to hide or disable the Close form button (red "X" in XP) at the top right of the titlebar of a windows form. I have found a work-around, but it would be easier to just hide the button.

 

Posted by: Michael Frayser
Post date: 11/10/2005 7:21:04 AM

RE: Disable or hide the form close button

What about Form1.ControlBox = false?

 

Posted by: Jason Newell
Post date: 11/10/2005 10:38:07 AM

RE: Disable or hide the form close button

Posted By Jason Newell on 11/10/2005 4:38:07 PM

What about Form1.ControlBox = false?

 

 

 

Duh! That was easy. I think I even used that in a VB class I took a couple of years ago. Thanks for the reminder!

 

 

Posted by: Michael Frayser
Post date: 11/11/2005 12:15:25 AM