me.close doesn't work!!!

  • Thread starter Thread starter Glyn Meek
  • Start date Start date
G

Glyn Meek

I have removed all the non relevant parts from the code with which I am
having problems, and this is the essence of it...

Dim frm As New EditContact

' LOAD UP THE DISPLAY FOR THE SELECTED CONTACT

frm.LoadData(MyContact, myLabel(currentfield))

' DISPLAY THE FORM

frm.ShowDialog()

' DETERMINE WHICH BUTTON WAS PRESSED TO EXIT THE CONTACT SCREEN

frm.GetData(ButtonPressed)

Me.Close()



I call the 'frm' to do just display some information (although at a later
date it will do much more), and on return I just want to close the calling
form without doing anything else, and return to the one that called it. (In
the actual code, the 'me.close' is surrounded by an IF statement dependent
on the value of ButtonPressed).

The me.close does NOT WORK in this example. Using the debugger, it just
merrily flies by and keeps going, NOT closing the form at all. The only way
I can get it to work is by clicking the 'OK' button on this 'returned to'
form, but the ONLY code in the click handler for the OK button is me. close!

It would seem that the form to which I return does not recognize the
me.close until an event has been triggered!

What am I doing wrong, or missing out here? Can anyone help???? I am not a
newbie at vb.net cf stuff by any means, but this one is baffling to me!

Regards and thanks

Glyn Meek
 
Have you tried setting the DialogResult property of the form instead, this
will set the return value and close the dialog.

Peter
 
Hello Peter...long time no chat!

Yes, I did try that as well, before I wrote the email. Here's how my called
form ends when I click a button called 'AllFieldsButton'...
Private Sub AllFieldsButton_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles AllFieldsButton.Click

ButtonPressed = UpdateAllFieldsExit

Me.DialogResult = DialogResult.OK

Me.Close()

End Sub



Any other ideas?

Regards

Glyn
 
Is the form you are trying to close the main application window? If not,
perhaps the form is actually getting closed, but the screen has not been
refreshed yet.

Just a shot in the dark!

Richard.
 
Good try Richard, and thanks, but NO..the screen I am trying to close is NOT
the main application window, and as I mentioned, once I actually 'click' on
the button before I execute the me.close, everything works fine!!

Glyn
 
Good try Richard, and thanks, but NO..the screen I am trying to close is NOT
the main application window, and as I mentioned, once I actually 'click' on
the button before I execute the me.close, everything works fine!!

Can you code up a very simple application that duplicates the problem and
post it? There must be something out of the ordinary going on.

Richard.
 
Back
Top