Disable the Close [X] Button in C#!
Posted: Sun Apr 03, 2011 4:10 pm
Since XTechVB did it in VB.NET I decided to convert it myself to C# AND HELP WITH CONVERTER
Create a new C# Project and double click or right click and click "View Code" to the code view!
Put this code above the public Form1()
So basically it will be:
ScreenShot:
Source Project: Enjoy the C# Code!
Create a new C# Project and double click or right click and click "View Code" to the code view!
Put this code above the public Form1()
Code: Select all
protected override CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
const int CS_NOCLOSE = 0x200;
cp.ClassStyle = cp.ClassStyle | CS_NOCLOSE;
CS_NOCLOSE.ToString().Trim();
return cp;
}
}
So basically it will be:
Code: Select all
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
const int CS_NOCLOSE = 0x200;
cp.ClassStyle = cp.ClassStyle | CS_NOCLOSE;
CS_NOCLOSE.ToString().Trim();
return cp;
}
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
ScreenShot:
Source Project: Enjoy the C# Code!