WinCE Forms的开幕式闭幕 [英] WinCE Forms Opening & Closing
问题描述
我在WinCE中的表单存在问题(很可能是一种理解).因此,由于我没有发布复杂的代码,因此我在一个简单的示例中重复了该问题;
I''m having a problem (most likely an understanding) with forms in WinCE. So as i don''t post complicated code i have replicated the problem in a simple example;
Public Class frmMain
Private Sub btnForm2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForm2.Click
Form2.Show()
End Sub
End Class
Public Class Form2
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Hide()
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'some code to add controls on the fly
End Sub
End Class
这与按要求打开和关闭表单的按钮配合得很好,但是,我想更改Form 2事件(btnClose),以便关闭表单,从而删除我即时添加的任何控件.如果我将事件更改为Me.Close(),则窗体将关闭,但无法使用Form 1中的按钮再次打开它,即:Form2.Show().(为什么我不知道).
我尝试过在隐藏之前在Form2上删除控件,但是在再次显示该窗体(Form2.Show)时,它不会转到Form2_Load,因此未添加新控件,因此我想关闭" Form2.
所以我的问题是,为什么Form2.Close阻止该窗体再次显示,并且解决方法是什么? -我敢肯定,这只是我对WinCE表格的理解不足.有什么想法吗?
This works well with the buttons opening and closing the forms as required however, i want to change the Form 2 event (btnClose) so that the form closes thus removing any controls i add on the fly. If i change the event to Me.Close() the form closes but i cannot open it again with the button in Form 1 ie: Form2.Show().(Why i don''t know).
I have tried removing the controls on Form2 just before the hide, but on showing the form again (Form2.Show) it doesn''t goto Form2_Load so new controls are not added thus my reason for wanting to ''Close'' Form2.
So my question is why does the Form2.Close stop the form from showing a second time and what is the workaround? - i''m sure this is just my poor understanding of WinCE forms. Any ideas?
推荐答案
好吧,我有一个解决方案-可行-尽管在我看来并不整洁;
基本上,将其公开后,只需调用"Load"子即可.
Ok i have one solution - which works - though is untidy in my view;
Basically just call the the ''Load'' Sub - after making it Public of course.
Public Class frmMain
Private Sub btnForm2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForm2.Click
Form2.Show()
Form2.Form2_Load()
End Sub
End Class
Public Class Form2
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
Me.Hide()
'for each ctr in me
'delete controls
'next
frmMain.Show()
End Sub
Public Sub Form2_Load() Handles MyBase.Load
'some code to add controls on the fly
End Sub
End Class
还是很想听听建议等等...
Would still love to hear suggestions etc...
这篇关于WinCE Forms的开幕式闭幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!