We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Close in load event in child form

Thread ID:

Created:

Updated:

Platform:

Replies:

8129 Oct 22,2003 12:58 PM UTC Apr 3,2004 11:17 AM UTC WinForms 1
loading
Tags: FAQ
Gvozden Radicevic
Asked On October 22, 2003 12:58 PM UTC

this sample fire exception "Cannot call Close() while doing CreateHandle()." 1. What is the cause of this error? 2. Is there any solution and if yes, what it would be? --- in main form Dim frm As New Form2 Try frm.MdiParent = Me frm.Show() Catch ex As Exception MessageBox.Show(ex.Message) End Try --- in child form Dim bUslov As Boolean Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load '---- code bUslov = True ' ----- code If bUslov Then Me.Close() End If End Sub

Michal Jirku
Replied On April 3, 2004 11:17 AM UTC

Yoy can not create Handle and then call Close() method. Try to set "frm.MdiParent = Me" after show method, outside try & catch block. >this sample fire exception "Cannot call Close() while doing CreateHandle()." > >1. What is the cause of this error? >2. Is there any solution and if yes, what it would be? > >--- in main form > > Dim frm As New Form2 > Try > frm.MdiParent = Me > frm.Show() > Catch ex As Exception > MessageBox.Show(ex.Message) > End Try > >--- in child form > > Dim bUslov As Boolean > > Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load > > ''---- code > > bUslov = True > > '' ----- code > > If bUslov Then > Me.Close() > End If > > End Sub > > > > > >

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;