private void button1_Click(object sender, EventArgs e)
{
this.ControlBox = false;
}
答案 0 :(得分:1)
添加以下库
using System.Runtime.InteropServices;
将以下内容声明为类级别变量
const int MF_BYPOSITION = 0x400;
[DllImport("User32")]
private static extern int RemoveMenu(IntPtr hMenu, int nPosition, int wFlags);
[DllImport("User32")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("User32")]
private static extern int GetMenuItemCount(IntPtr hWnd);
在Form_Load()事件中,编写以下代码
private void Form1_Load(object sender, EventArgs e)
{
IntPtr hMenu = GetSystemMenu(this.Handle, false);
int menuItemCount = GetMenuItemCount(hMenu);
RemoveMenu(hMenu, menuItemCount - 1, MF_BYPOSITION);
}
只需为ClickEvent
修改它答案 1 :(得分:0)
private const int dis_close_button = 0x200;
protected override CreateParams CreateParams
{
get
{
CreateParams ObjCP = base.CreateParams;
ObjCP.ClassStyle = ObjCP.ClassStyle | dis_close_button;
return ObjCP;
}
}
试试,这......