By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,834 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

How to prevent firing "Leave" event on open form??

P: n/a
Anyone know if this a bug in VB.NET 2002 and how to overcame that
situation?

I have a MDI form from where I call MDI child form like that:

Dim frm As New frmChild()
frm.MdiParent = Me
frm.Show()

On that child form I have some textboxes. When form show up Leave event
immediately fire in 1st textbox, but that should NOT happen in my
opinion.

Interesting is that this doesn't happen in VS 2003. Another observation
is that this doesn't happen if I open that form as non MDI child
(without "frm.MdiParent = Me" statement).

Any help or ideas how to prevent this will be very appreciated.
Regards,
Billy

Nov 21 '05 #1
Share this Question
Share on Google+
15 Replies


P: n/a
Billy,

This is the second time you ask this question and with the exact the same
text.

This is a very active newsgroup, so if somebody knows the answer you will be
answered and when it stays open some days our appreciated cleansweaper Peter
Huang will mostly search again for an answer.

When you want a quicker answer, than you can go to Microsoft support conform
the rules which exist for that.

Another approach can be to explain your problem in another way, by instance
with some code. How you create your MIDI child and what is maybe special on
your textbox.

Just my thought,

Cor

"Billy" <ab****@yahoo.com>
Anyone know if this a bug in VB.NET 2002 and how to overcame that
situation?

I have a MDI form from where I call MDI child form like that:

Dim frm As New frmChild()
frm.MdiParent = Me
frm.Show()

On that child form I have some textboxes. When form show up Leave event
immediately fire in 1st textbox, but that should NOT happen in my
opinion.

Interesting is that this doesn't happen in VS 2003. Another observation
is that this doesn't happen if I open that form as non MDI child
(without "frm.MdiParent = Me" statement).

Any help or ideas how to prevent this will be very appreciated.
Regards,
Billy

Nov 21 '05 #2

P: n/a
I don't know how to explain that easier. If you create a new project,
set main form as MDI container and from there call child form like I
wrote in my first post, you just have to check if leave event fires in
1st textbox when you open that child form. Maybe is problem just on my
PC?

Nov 21 '05 #3

P: n/a
Billy,

Did you do this test yourself with a *new* project, when not try it and tell
me the result?
\\\form1
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.IsMdiContainer = True
Dim frm As New Form2
frm.MdiParent = Me
frm.Show()
End Sub
///
\\\form2
Private Sub TextBox1_Leave(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles TextBox1.Leave
MessageBox.Show("Hello I am leaved")
End Sub
///
I hope this helps?

Cor
I don't know how to explain that easier. If you create a new project,
set main form as MDI container and from there call child form like I
wrote in my first post, you just have to check if leave event fires in
1st textbox when you open that child form. Maybe is problem just on my
PC?

Nov 21 '05 #4

P: n/a
I tried on brand new project. It's working if you open form2 with
Form1_Load event like you give example. But it won't work if you call
over menu or button later when main form is already displayed. Does it
work on your PC if you call form2 over menu?

Nov 21 '05 #5

P: n/a
Billy,

Private Sub Form12_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.IsMdiContainer = True
Dim frm As New Form2
frm.MdiParent = Me
frm.Show()
End Sub

Private Sub MenuItem1_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles MenuItem1.Click
Dim frm As New Form2
frm.MdiParent = Me
frm.Show()
End Sub
///

In this situation is twice the same form2 showed. In that the first showed
textbox looses his focus as the second form is showed and the event fires.

This logic you cannot prevent, because it happens. However you can catch
probably this situation depending on your program in your leave event by
setting a kind of switch. You can as well set the handlers programmicly,
however in your situation I would just do it with a switch

I hope this helps?

Cor

"Billy" <ab****@yahoo.com>
I tried on brand new project. It's working if you open form2 with
Form1_Load event like you give example. But it won't work if you call
over menu or button later when main form is already displayed. Does it
work on your PC if you call form2 over menu?

Nov 21 '05 #6

P: n/a
I think that this has to be a bug then, becuase if you will open form
over menu for example not as child (without frm.MdiParent = Me) then
Leave will not fire.

Regards,
Billy

Nov 21 '05 #7

P: n/a
Billy,

I agree, I think that it is the best that you get as quick as possible that
bug from your program.

Cor

"Billy" <ab****@yahoo.com>
I think that this has to be a bug then, becuase if you will open form
over menu for example not as child (without frm.MdiParent = Me) then
Leave will not fire.

Regards,
Billy

Nov 21 '05 #8

P: n/a
How you mean bug from my program? Do you say that "Leave" not fire in
your application if you open child form2 over menu or you joking from
from my problem?

If "Leave" fire with that call:
Dim frm As New frmChild()
frm.MdiParent = Me
frm.Show()

But not fire with that call (what is correct for Leave):
Dim frm As New frmChild()
frm.Show()

Then I missed something in my code. Can you tell me what?

Nov 21 '05 #9

P: n/a
Billy,

In the sample I gave you it *should* fire.

To give you an other sample, maybe you understand it than.
In this sample it will not fire the first time one the menuclick. However
when without doing something else the second time the mouse button is
clicked, it *should* fire for the form created with the first click or when
that MDI form is closed. When you do this with a normal form, that form does
not loose focus when the button is again clicked (but should when it
closes).

\\\
Private Sub Form12_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.IsMdiContainer = True
End Sub

Private Sub MenuItem1_Click(ByVal sender _
As System.Object, ByVal e As System.EventArgs) _
Handles MenuItem1.Click
Dim frm As New Form13
frm.MdiParent = Me
frm.Show()
End Sub
///.

I hope this makes it more clear,

Cor
"Billy" <ab****@yahoo.com>
How you mean bug from my program? Do you say that "Leave" not fire in
your application if you open child form2 over menu or you joking from
from my problem?

If "Leave" fire with that call:
Dim frm As New frmChild()
frm.MdiParent = Me
frm.Show()

But not fire with that call (what is correct for Leave):
Dim frm As New frmChild()
frm.Show()

Then I missed something in my code. Can you tell me what?

Nov 21 '05 #10

P: n/a
Billy,
Anyone know if this a bug in VB.NET 2002 and how to overcame that
situation? Interesting is that this doesn't happen in VS 2003.
I don't know specifically, if it occurs in .NET 1.0 (VS2002) & not in .NET
1.1 (VS2003), then that would be a good indication that a bug was fixed!
Would it not?

I would "overcome the situation" by upgrading to VS.NET 2003, especially if
you have already demonstrated to yourself that the problem is resolved in
VS2003!

Remember 2003 fixed a number of bugs in the IDE, made a number of
performance improvements in the IDE, plus .NET 1.1 fixed a number of bugs
from .NET 1.0. .NET 1.1 SP1 fixed a number of bugs in the framework, plus
added a couple of handy options...

In fact I would recommend you upgrade all the way to VS.NET 2002 w/.NET 1.1
SP1.

Hope this helps
Jay

"Billy" <ab****@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com... Anyone know if this a bug in VB.NET 2002 and how to overcame that
situation?

I have a MDI form from where I call MDI child form like that:

Dim frm As New frmChild()
frm.MdiParent = Me
frm.Show()

On that child form I have some textboxes. When form show up Leave event
immediately fire in 1st textbox, but that should NOT happen in my
opinion.

Interesting is that this doesn't happen in VS 2003. Another observation
is that this doesn't happen if I open that form as non MDI child
(without "frm.MdiParent = Me" statement).

Any help or ideas how to prevent this will be very appreciated.
Regards,
Billy

Nov 21 '05 #11

P: n/a
> In fact I would recommend you upgrade all the way to VS.NET 2003 w/.NET
1.1 SP1.
:)

Wonder why everybody didn't upgrade to VS 2003 (from 2002) when MS was
practically giving it away for $25? Better question: why did MS stop
offering the upgrade price???

Greg
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl... Billy,
Anyone know if this a bug in VB.NET 2002 and how to overcame that
situation?

Interesting is that this doesn't happen in VS 2003.


I don't know specifically, if it occurs in .NET 1.0 (VS2002) & not in .NET
1.1 (VS2003), then that would be a good indication that a bug was fixed!
Would it not?

I would "overcome the situation" by upgrading to VS.NET 2003, especially
if you have already demonstrated to yourself that the problem is resolved
in VS2003!

Remember 2003 fixed a number of bugs in the IDE, made a number of
performance improvements in the IDE, plus .NET 1.1 fixed a number of bugs
from .NET 1.0. .NET 1.1 SP1 fixed a number of bugs in the framework, plus
added a couple of handy options...

In fact I would recommend you upgrade all the way to VS.NET 2002 w/.NET
1.1 SP1.

Hope this helps
Jay

"Billy" <ab****@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Anyone know if this a bug in VB.NET 2002 and how to overcame that
situation?

I have a MDI form from where I call MDI child form like that:

Dim frm As New frmChild()
frm.MdiParent = Me
frm.Show()

On that child form I have some textboxes. When form show up Leave event
immediately fire in 1st textbox, but that should NOT happen in my
opinion.

Interesting is that this doesn't happen in VS 2003. Another observation
is that this doesn't happen if I open that form as non MDI child
(without "frm.MdiParent = Me" statement).

Any help or ideas how to prevent this will be very appreciated.
Regards,
Billy


Nov 21 '05 #12

P: n/a
Greg,
Wonder why everybody didn't upgrade to VS 2003 (from 2002) when MS was
practically giving it away for $25? I'm really not sure. I got the upgrade as part of my MSDN Universal
subscription...

I suspect its the "programming by rut" syndrome a number of developers have.
:-|
Better question: why did MS stop offering the upgrade price???

I really don't know, however I suspect it was a promotional gimmick in an
attempt to get people to upgrade...

Just a thought
Jay

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:eo**************@TK2MSFTNGP11.phx.gbl...
In fact I would recommend you upgrade all the way to VS.NET 2003 w/.NET
1.1 SP1.


:)

Wonder why everybody didn't upgrade to VS 2003 (from 2002) when MS was
practically giving it away for $25? Better question: why did MS stop
offering the upgrade price???

Greg
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Billy,
Anyone know if this a bug in VB.NET 2002 and how to overcame that
situation?

Interesting is that this doesn't happen in VS 2003.


I don't know specifically, if it occurs in .NET 1.0 (VS2002) & not in
.NET 1.1 (VS2003), then that would be a good indication that a bug was
fixed! Would it not?

I would "overcome the situation" by upgrading to VS.NET 2003, especially
if you have already demonstrated to yourself that the problem is resolved
in VS2003!

Remember 2003 fixed a number of bugs in the IDE, made a number of
performance improvements in the IDE, plus .NET 1.1 fixed a number of bugs
from .NET 1.0. .NET 1.1 SP1 fixed a number of bugs in the framework, plus
added a couple of handy options...

In fact I would recommend you upgrade all the way to VS.NET 2002 w/.NET
1.1 SP1.

Hope this helps
Jay

"Billy" <ab****@yahoo.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Anyone know if this a bug in VB.NET 2002 and how to overcame that
situation?

I have a MDI form from where I call MDI child form like that:

Dim frm As New frmChild()
frm.MdiParent = Me
frm.Show()

On that child form I have some textboxes. When form show up Leave event
immediately fire in 1st textbox, but that should NOT happen in my
opinion.

Interesting is that this doesn't happen in VS 2003. Another observation
is that this doesn't happen if I open that form as non MDI child
(without "frm.MdiParent = Me" statement).

Any help or ideas how to prevent this will be very appreciated.
Regards,
Billy



Nov 21 '05 #13

P: n/a
Greg,

Was it maybe because that it was a limited offer only for the USA and
Canada.

I remember me some very interesting discussions in this newsgroup from that
time, that I personally miss at the moment a little bit.

http://groups-beta.google.com/group/...e4f92f9f3005f4

http://groups-beta.google.com/group/...35e2f16c9643be

:-))

Cor
Nov 21 '05 #14

P: n/a
"Cor Ligthert" <no************@planet.nl> wrote in message
Was it maybe because that it was a limited offer only for the USA and
Canada.


Ah, did not know that. VS 2003 felt so much like a point release. I don't
understand why MS charges for the upgrade.

Greg

Nov 21 '05 #15

P: n/a
Thank you for your replay Jay and also to all other, special to you
Cor. I agree that the easiest will be just upgrade to 2003, but
customer wanted that in 2002 when started and because of that I was
looking for some kind solution in 2002.

Regards,
Billy

Nov 21 '05 #16

This discussion thread is closed

Replies have been disabled for this discussion.