How To Disable Close Button in Windows Form
Download Source Code : 307_CloseButton.zip
In this article i will try to explain you how you can disable Close Button in you windows application using Visual Basic.Net (VB.NET)
In some situation during your project you did not need or want the close button of your form. This article is about how you can disable the close button of your form using the window API’s.
- Steps you will do
- Start visual studio and create a new window application.
- Drop two button controls on the form.
- Set the properties of the First as below:
- Set the properties of the Second as below:
- Drop a label control on your form and set its Text property as below:
- Declare the following functions:
- Now write the following function which will disable the close button of your form.
- In the click event of “btnClose” write the code to exit from application as below:
· In the click event of “btnDisable” write call the “DisableCloseButton” function to disable the close button as below: