PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework Forms LostFocus seems to fire when I load the form

Reply

LostFocus seems to fire when I load the form

 
Thread Tools Rate Thread
Old 14-12-2005, 03:02 PM   #1
=?Utf-8?B?R2VvcmdpZUJS?=
Guest
 
Posts: n/a
Default LostFocus seems to fire when I load the form


Hi All,

I have a Windows MDI application which needs "modal type" dialog. Because
this can't be done inside MDI I want to display the lookup window and have it
close if the user clicks outside it.

So I load the lookup form, and I have the following code in the LostFocus:

<code>
Private Sub Lookup1_LostFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.LostFocus
Me.Close()
End Sub
</code>

However, as the form loads it goes through all it's usual load events and
finally I get an InvalidOperationException (Value Close() cannot be called
while doing CreateHandle())

Any ideas why the LostFocus is firing?

Many thanks in advance!
  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off