我有一个C#Form
,您在开始时显示Form1
,当您按Go
时,您将被带到Form2
。隐藏Form1
并显示Form2
。
现在退出form2
时,应关闭整个应用程序。当我按下退出按钮时,我正在使用Application.Exit()
。
如果用户按 X 或 ALT + F4 或RightClick->Close
,我将遇到问题。
表格将关闭,但隐藏的表格将保持打开状态。
我该如何解决?当我按下其中一个控制按钮时,所有隐藏的表格也会关闭?
我尝试了form1_Close
和Form1_Closing
功能,但它们似乎无法正常工作。
答案 0 :(得分:3)
试试这个:
Form1
当您关闭Form2
时,这将关闭RightClick -> Close
。如果用户在Form2
Form2
和Form1
上按 X 或 ALT + F4 或Array
(
[0] => Array
(
[entity_id] => 1
[value] => new
[label] => New
)
[1] => Array
(
[entity_id] => 3
[value] => pending_payment
[label] => Pending Payment
)
[2] => Array
(
[entity_id] => 4
[value] => pending_paypal
[label] => Pending Paypal
)
[3] => Array
(
[entity_id] => 5
[value] => processing
[label] => Processing
)
[4] => Array
(
[entity_id] => 6
[value] => complete
[label] => Complete
)
[5] => Array
(
[entity_id] => 7
[value] => canceled
[label] => Canceled
)
[6] => Array
(
[entity_id] => 8
[value] => closed
[label] => Closed
)
[7] => Array
(
[entity_id] => 9
[value] => holded
[label] => Holded
)
[8] => Array
(
[entity_id] => 10
[value] => payment_review
[label] => Payment Review
)
[9] => Array
(
[entity_id] => 11
[value] => new
[label] => New
)
[10] => Array
(
[entity_id] => 13
[value] => pending_payment
[label] => Pending Payment
)
隐藏$input = $my_array
$temp = $input;
foreach ( $temp as &$data ) {
unset($data['id']);
}
$output = array_intersect_key($input, array_unique($temp));
将关闭。
答案 1 :(得分:1)
使用Form2上的FormClosed event退出应用程序。
private void Form2_FormClosed(object sender, FormClosedEventArgs e)
{
Application.Exit();
}
答案 2 :(得分:-1)
~Form2() // destructor
{
application.exit();
}
当您按照指定关闭Form2时关闭它时,将调用此方法。