C# SuspendLayout一直给我一个期望
我正在尝试制作一个windows mobile应用程序,由于某种原因,SuspendLayout不断崩溃 它是如何崩溃的。我进入我的应用程序登录页面。然后我将手机旋转到横向并登录 然后我按下“OK”按钮,该按钮将关闭我访问的这个新表单。然后我回到登录页面,将手机旋转回纵向模式。然后我从表单(我刚刚关闭的表单)中得到一个expect 编辑 当方向改变或风景变为真时,我称之为。因为一个人可能会在登录表单上轮换,所以我的所有表单都必须调整以适应轮换 所以我有类似的东西C# SuspendLayout一直给我一个期望,c#,.net,winforms,windows-mobile,C#,.net,Winforms,Windows Mobile,我正在尝试制作一个windows mobile应用程序,由于某种原因,SuspendLayout不断崩溃 它是如何崩溃的。我进入我的应用程序登录页面。然后我将手机旋转到横向并登录 然后我按下“OK”按钮,该按钮将关闭我访问的这个新表单。然后我回到登录页面,将手机旋转回纵向模式。然后我从表单(我刚刚关闭的表单)中得到一个expect 编辑 当方向改变或风景变为真时,我称之为。因为一个人可能会在登录表单上轮换,所以我的所有表单都必须调整以适应轮换 所以我有类似的东西 //login form_l
//login
form_load
{
//figure out if they rotated this will be figured out by the SystemState.Change event that calls SetLayout that determine if they are in landscape or portrait.
// set landscape property to true if they are in landscape mode.
}
// form1
form_load
{
// generate default layout(formed for portrait)
// if landscape property is set to true Call SetLayout
// other wise just keep in default layout mode.
}
SetLayout()
{
SuspendLayout();
// code to determine if they are in portrait mode or landscape mode
// once determined change sizes and stuff for new mode.
// set static landscape property to true or false to use for future forms.
ResumeLayout();
}
如果用户再次(或首次在该表单上)更改轮换,将调用SystemState.Change is事件。这将调用SetLayout()。我猜您在表单上注册了事件(“PhoneRotated”),但在关闭表单之前没有取消注册。因此,当事件触发时,关闭的表单会收到通知,但无法执行SuspendLayout,因为您已经关闭了它。我认为您必须显示调用SuspendLayoutLaserCharger.LaserFired-=新事件处理程序(HandleLaserFireg);所以你认为我应该删除SystemState.Change?你需要取消注册
orientationChange\u Change
。我不知道它具体处理什么事件。只需调用用于注册方向更改的同一行,但使用-=而不是+=
//login
form_load
{
//figure out if they rotated this will be figured out by the SystemState.Change event that calls SetLayout that determine if they are in landscape or portrait.
// set landscape property to true if they are in landscape mode.
}
// form1
form_load
{
// generate default layout(formed for portrait)
// if landscape property is set to true Call SetLayout
// other wise just keep in default layout mode.
}
SetLayout()
{
SuspendLayout();
// code to determine if they are in portrait mode or landscape mode
// once determined change sizes and stuff for new mode.
// set static landscape property to true or false to use for future forms.
ResumeLayout();
}