Deriving from forms

J

Jayme.Pechan

Is it possible to allow derived forms to change the layout of the buttons
and UI elements on a form? For example, I make Form1 with a button in the
top left corner. I then make a Form2 that derives or inherits from Form1
and we see the button in the top left corner. I can not change the position
of the button in Form2 without changing it in Form1. I suppose this is
probably how it is supposed to work but I'd like to be able to reposition
the items on the form in Form2. Is this possible? How? Thanks.

Jayme
 
F

Fred Mellender

In the base form you must change the button's "Modifiers" attribute to
"Public" (or "Protected", etc). Since it defaults to "Private", you cannot
change it in the derived class. Hence the UI Designer blocks you from
changing it there too.
 
P

Peter Duniho

Is it possible to allow derived forms to change the layout of the
buttons and UI elements on a form? For example, I make Form1 with a
button in the top left corner. I then make a Form2 that derives or
inherits from Form1 and we see the button in the top left corner. I can
not change the position of the button in Form2 without changing it in
Form1. I suppose this is probably how it is supposed to work but I'd
like to be able to reposition the items on the form in Form2. Is this
possible? How? Thanks.

Not at design time, no. The base form defines the default location for
the control, and this can only be changed in the base form. But your
derived form certainly can rearrange things at run-time if you like. If
you have a good way of programmatically determining where you want the
button, then moving it in the constructor or the Load event handler may be
a good alternative for you.

Pete
 
P

Peter Duniho

[...]
Not at design time, no.

Sigh...yes, I'm a goof. Please ignore the above. Obviously you *can*
have the derived class initialize the control in a new place, as long as
the access to the control is set correctly.
 
F

Fred Mellender

I believe this is incorrect: if you change the "Modifiers" on the control,
in the base form, then the designer will let you move it in
the derived form. Then, you can change other attributes of the control in
the derived form as well (e.g. Enabled, etc).
 
P

Peter Duniho

I believe this is incorrect

I believe I beat you to pointing that out. :)

Yes, my post was wrong...trying to do too many things at once is not good
for thinking things through before posting, apparently. :) Sorry for the
confusion.

Pete
 
F

Fred Mellender

If I had a nickel for every incorrect post I made, I could buy a new
computer. I happened to know the answer to this question because I spent
quite a few minutes trying to figure out how to do this in a previous
project.

BTW, our series reinforces something I *thought* I had learned: wait a few
moments before replying to a post :)
 
J

Jayme.Pechan

That worked. thanks.

Jayme

Fred Mellender said:
In the base form you must change the button's "Modifiers" attribute to
"Public" (or "Protected", etc). Since it defaults to "Private", you
cannot change it in the derived class. Hence the UI Designer blocks you
from changing it there too.
 
G

Guest

Try

MyBaseControlName.Location = New Point (0, 0)
MyBaseControlName.Size = new Size(100, 40)
 

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