custom form control: Cannot view design view of forms that inherit this form 
Author Message
 custom form control: Cannot view design view of forms that inherit this form

Hi all,

I'm trying to create a custom form as a new custom control.  I then have a form (Form1) that inherits this custom form.  When I try
to go to the design mode of Form1, I get the following error:
    An exception occured while trying to create an instance of EzFormControls.cEzForm.
    The exception was "Object reference not set to an instance of an object."

So I went back to my customized form's code and put a bunch of msgbox() statements to debug this.
My customized form's New() gets called:
    Public Sub New(ByRef gGlobals As EzClasses.cGlobals)
        MyBase.New()
        'This call is required by the Windows Form Designer.
        InitializeComponent()
        ...

    <System.Diagnostics.De{*filter*}StepThrough()> Private Sub InitializeComponent()
        MsgBox("cEzForm: Inside InitializeComponent()")
        Me.StatusBar1 = New System.Windows.Forms.StatusBar()
        Me.mnuEzMain = New System.Windows.Forms.MainMenu()
        .....
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.StatusBar1})

        ' The following message box is the last thing that shows up
        MsgBox("cEzForm: Me.Menu -- Now it's going to die")
        Me.Menu = Me.mnuEzMain        =====> It dies here  <=====
        ' The following line never comes up
        MsgBox("cEzForm: Me.Name")

I'm very puzzled.  If the statement
    Me.StatusBar1 = New System.Windows.Forms.StatusBar()
gets executed, then the form control (Me) is instantiated as well as the main menu (mnuEzmain).
So if both of these are instantiated, what is the problem?

I've been working on this too hard & really want to make it work.  But don't know what to do next.

Thanks,
Omid



Sun, 20 Nov 2005 02:28:54 GMT  
 custom form control: Cannot view design view of forms that inherit this form
Perhaps you could get more detailed information if you put the offending
statement in a try...catch...end try block, and MsgBox the exception:

Try
    ...
Catch e as Exception
    MessageBox.Show(e.ToString)
End Try

Then, read the messagebox. It may not be the menu, but something else that
forbids menu creation.

--
Happy to help,
-- Tom Spink

Please respond to the newsgroup,
so all can benefit.

One Day,

Quote:
> Hi all,

> I'm trying to create a custom form as a new custom control.  I then have a

form (Form1) that inherits this custom form.  When I try
Quote:
> to go to the design mode of Form1, I get the following error:
>     An exception occured while trying to create an instance of

EzFormControls.cEzForm.
Quote:
>     The exception was "Object reference not set to an instance of an
object."

> So I went back to my customized form's code and put a bunch of msgbox()

statements to debug this.
Quote:
> My customized form's New() gets called:
>     Public Sub New(ByRef gGlobals As EzClasses.cGlobals)
>         MyBase.New()
>         'This call is required by the Windows Form Designer.
>         InitializeComponent()
>         ...

>     <System.Diagnostics.De{*filter*}StepThrough()> Private Sub

InitializeComponent()
Quote:
>         MsgBox("cEzForm: Inside InitializeComponent()")
>         Me.StatusBar1 = New System.Windows.Forms.StatusBar()
>         Me.mnuEzMain = New System.Windows.Forms.MainMenu()
>         .....
>         Me.Controls.AddRange(New System.Windows.Forms.Control()
{Me.StatusBar1})

>         ' The following message box is the last thing that shows up
>         MsgBox("cEzForm: Me.Menu -- Now it's going to die")
>         Me.Menu = Me.mnuEzMain        =====> It dies here  <=====
>         ' The following line never comes up
>         MsgBox("cEzForm: Me.Name")

> I'm very puzzled.  If the statement
>     Me.StatusBar1 = New System.Windows.Forms.StatusBar()
> gets executed, then the form control (Me) is instantiated as well as the

main menu (mnuEzmain).
Quote:
> So if both of these are instantiated, what is the problem?

> I've been working on this too hard & really want to make it work.  But

don't know what to do next.

- Show quoted text -

Quote:

> Thanks,
> Omid



Sun, 20 Nov 2005 02:36:45 GMT  
 custom form control: Cannot view design view of forms that inherit this form
I am looking at the exception detail & still don't understand what's going on.  I understand that some object does not exist.  It
cannot be the form itself because there are numerous references to Me.  It also cannot be the main menu item because at the
beginning of the routine it's instantiated:
    Me.mnuEzMain = New System.Windows.Forms.MainMenu()

The line that's blowing up:
    Me.Menu = Me.mnuEzMain

Here's the error:
System.NullReferenceException: Object reference not set to an instance of an object.
   at EzFormControls.cEzForm.cEzForm_Resize(Object sender, EventArgs e) in C:\Omid\VB .NET\Ezware\EzFormControls\cEzForm.vb:line 203
   at System.Windows.Forms.Control.OnResize(EventArgs e)
   at System.Windows.Forms.Form.OnResize(EventArgs e)
   at System.Windows.Forms.Control.OnSizeChanged(EventArgs e)
   at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight)
   at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height)
   at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified)
   at System.Windows.Forms.Form.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified)
   at System.Windows.Forms.Control.SetBounds(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified)
   at System.Windows.Forms.Control.set_Size(Size value)
   at System.Windows.Forms.Control.SetClientSizeCore(Int32 x, Int32 y)
   at System.Windows.Forms.Form.SetClientSizeCore(Int32 x, Int32 y)
   at System.Windows.Forms.Control.set_ClientSize(Size value)
   at System.Windows.Forms.Form.set_ClientSize(Size value)
   at System.Windows.Forms.Form.set_Menu(MainMenu value)
   at EzFormControls.cEzForm.InitializeComponent() in C:\Omid\VB .NET\Ezware\EzFormControls\cEzForm.vb:line 169



Sun, 20 Nov 2005 06:02:00 GMT  
 custom form control: Cannot view design view of forms that inherit this form
Hmm..... this is occurring in the OnResize event??? Try this line:

If Not Me.mnuEzMain Is Nothing Then Me.Menu = Me.mnuEzMain

--
Happy to help,
-- Tom Spink

Please respond to the newsgroup,
so all can benefit.

One Day,

Quote:
> I am looking at the exception detail & still don't understand what's going

on.  I understand that some object does not exist.  It
Quote:
> cannot be the form itself because there are numerous references to Me.  It

also cannot be the main menu item because at the
Quote:
> beginning of the routine it's instantiated:
>     Me.mnuEzMain = New System.Windows.Forms.MainMenu()

> The line that's blowing up:
>     Me.Menu = Me.mnuEzMain

> Here's the error:
> System.NullReferenceException: Object reference not set to an instance of
an object.
>    at EzFormControls.cEzForm.cEzForm_Resize(Object sender, EventArgs e) in

C:\Omid\VB .NET\Ezware\EzFormControls\cEzForm.vb:line 203
Quote:
>    at System.Windows.Forms.Control.OnResize(EventArgs e)
>    at System.Windows.Forms.Form.OnResize(EventArgs e)
>    at System.Windows.Forms.Control.OnSizeChanged(EventArgs e)
>    at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32

width, Int32 height, Int32 clientWidth, Int32 clientHeight)
Quote:
>    at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32

width, Int32 height)
Quote:
>    at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32

width, Int32 height, BoundsSpecified specified)
Quote:
>    at System.Windows.Forms.Form.SetBoundsCore(Int32 x, Int32 y, Int32

width, Int32 height, BoundsSpecified specified)
Quote:
>    at System.Windows.Forms.Control.SetBounds(Int32 x, Int32 y, Int32

width, Int32 height, BoundsSpecified specified)
Quote:
>    at System.Windows.Forms.Control.set_Size(Size value)
>    at System.Windows.Forms.Control.SetClientSizeCore(Int32 x, Int32 y)
>    at System.Windows.Forms.Form.SetClientSizeCore(Int32 x, Int32 y)
>    at System.Windows.Forms.Control.set_ClientSize(Size value)
>    at System.Windows.Forms.Form.set_ClientSize(Size value)
>    at System.Windows.Forms.Form.set_Menu(MainMenu value)
>    at EzFormControls.cEzForm.InitializeComponent() in C:\Omid\VB

.NET\Ezware\EzFormControls\cEzForm.vb:line 169


Sun, 20 Nov 2005 20:10:11 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Setting Properties - Design View vs Form View

2. Can't open VB.NET form in design view (only get code view)

3. Controls Disappear in VS.NET Form Design view

4. problem viewing an inherited form in IDE

5. design form view

6. Invalid URL error when trying to open web form in design view

7. Urgent help - Error while opening Form design view on MS Visual Basic.Net

8. Form View/Table View

9. Form view / datasheet view, subform only

10. Out of memory error when opening form in design view

11. IDE crashes when viewing form in design mode

12. Problems viewing forms in design mode

 

 
Powered by phpBB® Forum Software