How to disable the close button in windows form application in C#

By | 23rd October 2019

Hi Guys Here I will show you how to disable the close button in windows form application in C#

Declare the constant variable :

private const int CP_NOCLOSE_BUTTON = 0x200;

Now, define protected override method as shown:

protected override CreateParams CreateParams
{
get
{
CreateParams myCp = base.CreateParams;
myCp.ClassStyle = myCp.ClassStyle | CP_NOCLOSE_BUTTON;
return myCp;
}
}

Happy Coding Guys 🙂

Class Definition and Using Select statement adding the data to the predefined list

How to track the deleted folders in Windows Explorer in Windows Forms Application in C# .net