Click here to Skip to main content
15,881,741 members

WinCE Forms Opening & Closing

Synth_Boy asked:

Open original thread
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;

VB
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

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?
Tags: Visual Basic, .NET

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900