473,659 Members | 2,886 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 1468
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.Pech an" <ja***@pechan.u swrote in message
news:9D******** *************** ***********@mic rosoft.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.u swrote:
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 programmaticall y 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*********@nn owslpianmk.comw rote:
[...]
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*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
On Tue, 05 Jun 2007 11:35:03 -0700, Jayme.Pechan <ja***@pechan.u swrote:
>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 programmaticall y 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************ ****@frontierne t.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*********@nn owslpianmk.comw rote in message
news:op******** *******@petes-computer.local. ..
On Tue, 05 Jun 2007 11:59:47 -0700, Fred Mellender
<no************ ****@frontierne t.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************ ****@frontierne t.netwrote in message
news:Me******** *********@news0 1.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.Pech an" <ja***@pechan.u swrote in message
news:9D******** *************** ***********@mic rosoft.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

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

"Jayme.Pech an" 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
11023
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 the following code: class CFENException : public std::exception { std::string _what; public:
28
4081
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 across any examples of a construct like what I show below. Perhapes it's simply a bad idea. If there is something fundamentally wrong with this approach please let me know. Can anybody tell me if there is a way to get the following to work? I...
8
2833
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 list class must Ioverride in order for this to work?
2
1217
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. How would I set this up in my base form and how would I set it ip in forms that derive from it. Samples would be great. Thanks Ryan
8
1328
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 form B from it Firstly the menu that the MSDN says should be available from the 'Add' menu to 'Add an Inherited Form' isn't there This seems to only be available for C# and VB.Net
2
1649
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 create a second interface that specifices the second type argument. I also want to have objects implement that second interface without having to implement the more generic methods that are inherited from the first. This is especially evident...
15
4075
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 containers destructors virtual >
1
3496
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 idea? I was under the impression that deriving from std classes that do not have virtual methods was bad. Is ostream designed to be derived from? If, so are there any resources on how to do this properly? ostream has alot if internals that look...
3
3429
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 typeid(p).name(); }
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8332
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6179
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2750
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 we have to send another system
2
1737
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.