Inherited Form - Question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Miro

    Inherited Form - Question

    I am starting to think my reason for an inherited form is flawed.

    My original concept was this:
    Create a form with a panel near the top with a button in the top right
    corner, and then a panel in the middle.

    ( Basically a basic template of all my forms ).

    So I created that form and compiled it.
    Then I added an inherted form and made it inherit from the orig form.

    Now I try to add a button to the main panel and cannot.
    So I go back to the main form, change the modifiers from "Friend" to
    "Protected" and then recompile and then go back to the designer.

    Now I can add buttons to the main panel.
    But now I can also resize the main panel, change the main panel, do anything
    to the main panel. I wanted the panel to 'hold position',
    and make it 'not changable' but still add items ontop of it.

    So my initial idea does not work.
    It seems I should just create a dummy form in my project, and when I want to
    create a new form, just copy it.
    As there really is no difference by me setting almost all the items on the
    form to be "Protected" .

    Thanks,

    Miro


  • Miro

    #2
    Re: Inherited Form - Question

    As I just typede this message I think I came up with a solution.

    The 'Main Panel' I set to Friend, but then I added a panel ontop of it, and
    Docked it within the Friend Panel, and made it Protected.

    Thus, when inherting in the other form, I cannot easily change the panel
    layout ( of where it is ) but still am able to add items to it.

    Sorry for the posting(s). Sometimes it just seems to help to try to explain
    it to someone to see the solution.

    Miro

    "Miro" <miro@beero.com wrote in message
    news:OqM4ImKBJH A.4664@TK2MSFTN GP05.phx.gbl...
    >I am starting to think my reason for an inherited form is flawed.
    >
    My original concept was this:
    Create a form with a panel near the top with a button in the top right
    corner, and then a panel in the middle.
    >
    ( Basically a basic template of all my forms ).
    >
    So I created that form and compiled it.
    Then I added an inherted form and made it inherit from the orig form.
    >
    Now I try to add a button to the main panel and cannot.
    So I go back to the main form, change the modifiers from "Friend" to
    "Protected" and then recompile and then go back to the designer.
    >
    Now I can add buttons to the main panel.
    But now I can also resize the main panel, change the main panel, do
    anything to the main panel. I wanted the panel to 'hold position',
    and make it 'not changable' but still add items ontop of it.
    >
    So my initial idea does not work.
    It seems I should just create a dummy form in my project, and when I want
    to create a new form, just copy it.
    As there really is no difference by me setting almost all the items on the
    form to be "Protected" .
    >
    Thanks,
    >
    Miro
    >
    >

    Comment

    • Phill W.

      #3
      Re: Inherited Form - Question

      Miro wrote:
      My original concept was this:
      Create a form with a panel near the top with a button in the top right
      corner, and then a panel in the middle.
      So I created that form and compiled it.
      Then I added an inherted form and made it inherit from the orig form.
      Now I can add buttons to the main panel.
      But now I can also resize the main panel, change the main panel, do
      anything to the main panel. I wanted the panel to 'hold position',
      and make it 'not changable' but still add items ontop of it.
      You're heading in the /right/ direction!

      Take control of the Layout of your Base Form:

      Protected Overrides Sub OnLayout( _
      ByVal e as LayoutEventArgs _
      )
      ' Let VB do it's thing ...
      MyBase.OnLayout ( e )

      ' ... then put things where you want them to be!
      With Me.MainFrame
      .Location = ...
      .Size = ...
      End With

      ' ... and so on ...

      End Sub

      This code will run even in the Designer so Developers can't go
      rearranging your form - the Layout code will simply put it straight back
      again.

      HTH,
      Phill W.

      Comment

      Working...