public void AltF4(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
base.OnClosing(e);
}
它告诉我Object
没有OnClosing
的定义。谁能告诉我为什么?
答案 0 :(得分:0)
如评论中所述,您可以尝试以下方式:
protected override void OnFormClosing(FormClosingEventArgs e)
{
if (e.CloseReason != CloseReason.WindowsShutDown
&& e.CloseReason != CloseReason.ApplicationExitCall
&& e.CloseReason != CloseReason.FormOwnerClosing )
{
e.Cancel = true;
}
base.OnFormClosing(e);
}
希望这可能会有所帮助。