Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Prevent an MDI child form from closing 2

Status
Not open for further replies.

T0AD

Programmer
Jun 4, 2003
73
GB
Is it possible to disable the X button on an MDI child form? Or, make it so that when the X is clicked, the form hides rather than closes?

T0AD
 
on button click event use public method Hide to conceal the form.

Hiding the control is equivalent to setting the Visible property to false. After the Hide method is called, the Visible property returns a value of false until the Show method is called.



===Please visit FAQs to view my contributions.===
 
Okay maybe I wasn't very clear. I want the cross on the child window (you know, the close button - next to the minimize and restore buttons!) to be disabled.

Alternatively I want to be able to access (override maybe) the close event, and hide the form instead of closing. (I know how to hide a form...)

Sorry for the confusion! :)
 
You need to handle the Closing event and set the cancel event argument to True. Then hide the form

Private Sub FormClosing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
e.Cancel = True
Me.Hide()
End Sub

===Please visit FAQs to view my contributions.===
 
Great, thanks very much PankajBanga
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top