Unable to edit/move/remove controls in Subclassed form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am subclassing a Form and cannot edit, move or remove controls - or change
their properties. A little lock appears by each control. This is in VS2005.

How can I control what can be done to subforms, for instance if I were to
give my forms to someone and let them derive subclasses and modify them in a
controled way?
 
Hi Juan,

When we add a control onto a form, the default value of the Modifiers
property is 'Private', which means that this control couldn't be accessed
out of the form, including its inherited forms.

To make the control on the base form available to its inherited forms, we
set the Modifiers property of the control to 'Public' or 'Protected'. Build
the project and reopen the inherited form in the designer and you will see
the control on the inherited form is modifiable.

FYI, many new controls in VS2005 don't take the visual inheritance scenario
into account when originally designed. That is, even if you set the
Modifiers property of these controls to 'Public' or 'Protected' on the base
form, they are still NOT modifiable on the inherited form at design-time
(don't worry about it, these controls is modifiable in the inherited form
by code). This behavior is by design.

These controls are listed below.

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

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.
 
Hi,

Yes, I found that out myself the other day. Yet, I guess my question is, is
there some way to configure or control which kinds of editions can be done in
subforms?
I read something about this some months ago and now I can't remember exactly
what it was, but it as related to this or a way to do this...
Any ideas?
--
Thanks in advance,

Juan Dent, M.Sc.
 
Hi Juan,

As far as I know, we couldn't configure or control which kind of edition
can be done in inherited forms.

If we set the Modifiers property of a control on the base form to
'Private', we couldn't access or modify the control in an inherited form.
If we set the Modifiers property to 'Public' or 'Protected', we could
access and modify every part of the control on an inherited form.

Could you tell me why you want to control which kinds of editions can be
done in an inherited form?


Sincerely,
Linda Liu
Microsoft Online Community Support
 
Hi,

I want to control which kinds of editions can be done in the inherited form
because I want the end customer to be able to customize some parts of the UI,
but not all.
That's pretty much it...
 
Hi Juan,

I understand what you mean.

When we set the Modifiers property of a control on a base form to 'Public'
or 'Protected', we could access this control in an inherited form just like
in the base form, which means we can edit every part of the control in the
inherited form that we can edit in the base form.

However, we can control which part of a control can be edited on a form by
setting the Modifiers property of those properties which CAN be edited to
'Public' and set the Modifiers property of those properties which CAN NOT
be edited to 'Private'.

If the control is a standard .NET framework control, e.g TextBox, ComboBox
and so on, we may wrap it in a usercontrol. That is, create a UserControl
and add the standard control into it. Only expose those properties of the
standard control which are going to be modifiable and set the Modifiers
property of these properties to 'Public' in the usercontrol. Add some
public methods to get/set the properties of the standard control we don't
expose if necessary.

Then when we add this usercontrol onto the base form, only the public
properties in the usercontrol can be edited. We could call the public
methods in the usercontrol to get/set some private properties by code in
the base form. Build the project and create an inherited form. You will
find you could only edit the exposed public properties of the usercontrol
on the inherited form at least at design-time.

Hope this helps.
If you have any concerns, please feel free to let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support
 
Back
Top