Can't add controls on inherited form

M

Mikus Sleiners

I can't seem to add new controls to form that is inherited from another
form.

I have BaseForm wich have table layout on it 2 panelsm and some buttons.
Now i create InheritedForm : BaseForm and want to add some new controls and
add them to pannels
but i can't drag and drop them ... designer does not allow me. Why is that ?

Panels and table layout modifiers is set to public.

I could not add my test solution to this post, cuz it said it's too big. I
dono why.. it's under 1mb ?
Please download it from :
http://www.svara-kontrole.lv/silo/FormInheritanceExample.rar
 
L

Linda Liu [MSFT]

Hi Mikus,

Generally speaking, when we set the Modifiers property of a control on a
base form to 'Public' or 'Protected', we can configure this control on an
inherited form just like on the base form.

However, many new controls of VS2005 didn't take the visual inheritance
scenario into account when originally designed. That's to say, even if we
set the Modifiers property of these control to 'Public' or 'Protected' on
the base form, we can not configure them on an inherited form.

These controls that don't support visual inheritance are listed below.

ToolStrip, MenuStrip, ContextMenuStrip and StatusStrip
ToolStripContainer
ToolStripPanel
SplitContainer
TableLayoutPanel
FlowLayoutPanel
DataGridView
MaskedTextBox
WebBrowser

Although we can not configure these control on the inherited form in the
designer, we could still access them by code, e.g. add a control in the
TableLayoutPanel.

Hope this helps.
If you have anything unclear, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

stroudpete

Although we can not configure these control on the inherited form in the
designer, we could still access them by code, e.g. add a control in the
TableLayoutPanel.

Hope this helps.

It might help Mikus but it doesn't help me.

I'm writing an app where I have a form which is inherited by 10 or so
other forms. On it I have a panel. I have recently added functionality
on an inherited form to put more controls "alongside" the panel. As
they were all related and sometimes needed to be hidden, I put them in
a second panel. Hopeless! Every time I build the project the 2nd panel
resizes itself (trebles in size, at least) and the form resizes. It's
nothing to do with code in the form onload event (been there, if
designtime'd that), it just won't stay the original size. So, I've had
to ditch the panel and replace it with a group box.

I now want to put similar 2nd "panels" in all the forms, so back to the
base form, and knowing a 2nd panel wouldn't work (and required quite a
bit of controling) I went for a splitcontainer - it's perfect for the
task. Until I discovered it's useless. "Doesn't support inheritance in
the designer 'cos the developers of an object oriented development
environment didn't take visual inheritance into account when designing
a visual control". Have the team concerned been put up against a wall
and shot? No? Well, they should have been! A great product made better
by the addition of some excellent new controls, but let down by shoddy
management - who the hell was responsible for controling that part of
the development?

As to adding the controls into the inherited forms in the code, what a
laugh! I've around 60 controls on some of the forms. What's the point
of a visual designer if I have to do it all by hand.

No, stuff it. I'll have to put the "2nd panel" in a group box on the
main form, and the appropriate control to hide it when applicable. Oh,
I should mention the major control in the "2nd panel" is a
DataGridView. What's that you say - oh, yes, that doesn't support
visual inheritance at design time either.

As this is a very public arena, I'll just say I'm extremely displeased.
It's a good job we haven't got to the point where my verbal background
comments are automatically picked up and included in postings.
 
S

stroudpete

Ok, maybe it's me that needs putting up against a wall and shooting! I
should not have posted until I'd actually tried what the poster above
said didn't work, ie. changing the modifier to Public. I did this to
the splitcontainer and the datagridview I placed in the right panel,
and everything works a treat in the inheriting form. I can drop
controls into the splitcontainer with no problem. Resizing does not
happen at build time and I can add controls in the designer. Indeed, I
took my version one form, selected all the controls below form level,
copied and pasted them into the left panel of my version 2 inheritng
form, and hey presto, I had my new format form in seconds.

So, I am eating humble pie in public as I'm not too proud to admit I
was hasty in my response (mind you, if Microsoft don't think this
should have worked because they didn't develop the control with visual
inheritance in the designer in mind, my comments weren't totally out of
order). Anyway, it's right I do this just in case anyone else is having
a similar problem, searches, and finds the negatives above. If you are
that person, all is NOT lost - just try it and see if it works for you!
 

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