Inherited Form - Question

M

Miro

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
 
M

Miro

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
 
P

Phill W.

Miro said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top