tags:

views:

140

answers:

2

I have tried : ParentForm.ControlBox = false;

... but it doesn't seem to work ... the ControlBox is still enabled!

Any ideas?

/I don't want to use the Win32 interop method to disable the 'X'. Disabling the ControlBox is fine.

+1  A: 

Have you tried using the FindForm() method instead? It seems as if the ParentForm property can return a null reference (not sure under which circumstances yet, though). It did for me now when I created an empty UserControl and added it to a form. Disabling the ControlBox through FindForm worked well though.

Fredrik Mörk
A: 

ParentForm.ControlBox = false, should work

In C# just add

    protected override void OnClosing(CancelEventArgs e)
    {
        e.Cancel = true;
    }

this will not disable the ControlBox but will prevent window from closing

pixel3cs