Results 1 to 11 of 11

Thread: Inheriting a form... Base class form's controls are not showed in designer?!!!

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Inheriting a form... Base class form's controls are not showed in designer?!!!

    I dont know if anyone has experienced this, but it is REALLY frustrating.
    I have a form called frmBase... I have a bunch of controls and a little bit of code on that form.
    Now there is another form which inherits from frmBase. The problem is that none of the controls on frmBase show up on the inherited form (at design time). If I run the application and open up the inherited form, all the inherited controls show up. But for some reason I cant see them at design time.

    Any one has a solution? I dont know how to get around this. It would seem really stupid if VS.NET doesnt support showing of inherited controls. I know you can see them in an inherited usercontrol.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    There is something called visual inheritance, have you tried that?

  3. #3
    PowerPoster
    Join Date
    Mar 2002
    Location
    UK
    Posts
    4,780
    Yup, Ive had that before. The form has just screwed up.

    Its sometimes happens on just normal forms, where all the controls dissaper as well.

    Re-make the form.

    Heres the basic code for an inherited form. Just add a new .vb file to the project (New item, VB codefile), paste this in, change the name at the top. Then move over all the changes you have made to the new inherited form. Or just use the new inherited form button .


    Code:
    Public Class Form2
        Inherits Test1.Form1
    
    #Region " Windows Form Designer generated code "
    
        Public Sub New()
            MyBase.New()
    
            'This call is required by the Windows Form Designer.
            InitializeComponent()
    
            'Add any initialization after the InitializeComponent() call
    
        End Sub
    
        'Form overrides dispose to clean up the component list.
        Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
            If disposing Then
                If Not (components Is Nothing) Then
                    components.Dispose()
                End If
            End If
            MyBase.Dispose(disposing)
        End Sub
    
        'Required by the Windows Form Designer
        Private components As System.ComponentModel.IContainer
    
        'NOTE: The following procedure is required by the Windows Form Designer
        'It can be modified using the Windows Form Designer.  
        'Do not modify it using the code editor.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            components = New System.ComponentModel.Container()
        End Sub
    
    #End Region
    
    End Class

  4. #4

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    hmm seems stupid. Somes it works sometimes it doesnt? blah, I'm gonno go home and try it again... so frustrating!

    btw what is visual inheritance?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  5. #5
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    I'm using VS 2002, and I haven't experienced that behavior. Perhaps you should try removing, and then, adding the forms back to the Solution.

  6. #6
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    I have had this, but much worse. It appears that M$ is having trouble with inherited forms and controls. You have to place your super forms and controls in a separate project to the sub controls and forms. In addition they also have the same problem with usercontrols. The M$ recommend putting the user controls into a separate project.

  7. #7
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    The form you wish to inherit from has to be either compiled into an assembly (.dll || .exe), or you must reference the project.

  8. #8

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Lethal
    The form you wish to inherit from has to be either compiled into an assembly (.dll || .exe), or you must reference the project.
    umm but it gives you the option to inherit from a form in your own project

    So I should put the base class form in a separate project? aah that just adds another dll to my project
    and yeah, I've had a lot of headaches with inherited usercontrols
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  9. #9

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Lethal
    The form you wish to inherit from has to be either compiled into an assembly (.dll || .exe), or you must reference the project.
    WHAT THE HELL !!! aaah
    this isnt working
    I tried it several times again, I even made a separate project, and inherited the form from that project, as you said.

    First of all, I dont have a sub New(). My constructor gets arguments. So when I want to design the inherited form I get an error message and it doesnt show the design environment. If I add a no-argument constructor to my base class, then the same old thing that I described happens: the controls dont show up at design time

    HELP!!!!
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  10. #10
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769
    You have a constructor that takes parameters ... ? This may be your problem. Remember that when you inherit from your base form, it will run all the initialization code within that base form. Make sure that you r not running any code (at design time) which should only be run at run-time. I stand to be corrected, but I think there is a property of all controls (InDesign or something like that) which returns true when the application is running in at design time. You should check this value before excecuting any code in you base form.

    As for the separate assembly issue, M$ have said that there is a problem with controls and inherited forms etc. and they recommend placing them in separate assemblies. Whether or not this works I don't know.

  11. #11

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    yeah it seems like there is in fact a problem with the inherited controls. As for using a different assembly, that didnt change a thing (by that, I mean I put it on a separate project and then referenced the base form to my project to inherit from it.. I guess thats what I was supposed to do)

    No, its not with my code. I tested it with other stuff, doesnt work
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width