473,503 Members | 1,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Deriving from forms

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

Jun 5 '07 #1
8 1462
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.
"Jayme.Pechan" <ja***@pechan.uswrote in message
news:9D**********************************@microsof t.com...
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

Jun 5 '07 #2
On Tue, 05 Jun 2007 11:35:03 -0700, Jayme.Pechan <ja***@pechan.uswrote:
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
Jun 5 '07 #3
On Tue, 05 Jun 2007 11:52:31 -0700, Peter Duniho
<Np*********@nnowslpianmk.comwrote:
[...]
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.
Jun 5 '07 #4
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).

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Tue, 05 Jun 2007 11:35:03 -0700, Jayme.Pechan <ja***@pechan.uswrote:
>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

Jun 5 '07 #5
On Tue, 05 Jun 2007 11:59:47 -0700, Fred Mellender
<no****************@frontiernet.netwrote:
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
Jun 5 '07 #6
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 :-)

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Tue, 05 Jun 2007 11:59:47 -0700, Fred Mellender
<no****************@frontiernet.netwrote:
>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

Jun 5 '07 #7
That worked. thanks.

Jayme

"Fred Mellender" <no****************@frontiernet.netwrote in message
news:Me*****************@news01.roc.ny...
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.
"Jayme.Pechan" <ja***@pechan.uswrote in message
news:9D**********************************@microsof t.com...
>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

Jun 5 '07 #8
Try

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

"Jayme.Pechan" wrote:
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
Jun 6 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11002
by: Noah Roberts | last post by:
I am having some problems with deriving the std::exception class. My compiler (g++-2.95) works with it just fine, but it does in a lot of broken cases. I have a user/developer that can't compile...
28
4049
by: Steven T. Hatton | last post by:
This may be another question having an obvious answer, but I'm not seeing it. I'm trying to create a class that derives from std::valarray<std::string>. I don't need a template, and I haven't come...
8
2827
by: JustSomeGuy | last post by:
I need to write an new class derived from the list class. This class stores data in the list to the disk if an object that is added to the list is over 1K in size. What methods of the std stl...
2
1209
by: Ryan Wade | last post by:
I want to create a base form to derive all my forms from. In the base for I want a KeyPress event to fire that when the enter key is pressed it acts like the tab key and moves to the next control....
8
1324
by: Vincent Finn | last post by:
I know the answer to the question above is yes but my reason for asking is that it doesn't seem to work properly I have a manged C++ WinForms project In it I have a form A, I want to derive a...
2
1643
by: PMarino | last post by:
Hi all - I'm sure I'm being brain-dead here - and I think the answer is 'you can't do that', but I thought I would try. I have an interface that is Generic, with two type arguments. I want to...
15
4052
by: Nindi73 | last post by:
HI If I define the class DoubleMap such that struct DoubleMap : public std::map<std::string, double>{}; Is there any overhead in calling std::map member functions ? Moreover are STL...
1
3482
by: Christopher Pisz | last post by:
I set out to make a custom logger. Examining some other code laying around, I came across one that derived from ostream, and had a associated class derived from streambuf. Is this practice a good...
3
3420
by: Al Grant | last post by:
Consider two translation units, (1): namespace { struct S { }; } struct D: S { virtual int f(void); }; and (2): #include <typeinfo> struct D; char const *f(D *p) { return...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7348
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5021
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4685
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1519
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
397
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.