471,571 Members | 1,045 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,571 software developers and data experts.

Prevent UserControl derivative from being designed

Hi. I have a class derived from a UserControl,
that I want to allow others to derive controls
from. I don't want them to design the base
class (which is derived from a UserControl).

I know that I can prevent the control from being
designed by making it not the first class in the
code file, but is there another more 'official' way
to do this via attributes.

The user should be able to add the control's source
to a project (or reference it in another assembly),
and then select the control in the Inheritance Picker,
to create a derived class, but I want to prevent the
user from designing the base class.

--
Tony M.
Nov 17 '05 #1
3 1576
Doing it with source is pointless because an enterprising programmer will
just alter the source to suit his needs.

If you distribute as a DLL then the problem goes away because you can't
alter the class once it's compiled.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Tony Maresca" <to**@whereever.com> wrote in message
news:Oa**************@TK2MSFTNGP15.phx.gbl...
Hi. I have a class derived from a UserControl,
that I want to allow others to derive controls
from. I don't want them to design the base
class (which is derived from a UserControl).

I know that I can prevent the control from being
designed by making it not the first class in the
code file, but is there another more 'official' way
to do this via attributes.

The user should be able to add the control's source
to a project (or reference it in another assembly),
and then select the control in the Inheritance Picker,
to create a derived class, but I want to prevent the
user from designing the base class.

--
Tony M.

Nov 17 '05 #2
Tony Maresca wrote:
Hi. I have a class derived from a UserControl, that I want to allow
others to derive controls from. I don't want them to design the base
class (which is derived from a UserControl).

I know that I can prevent the control from being designed by making
it not the first class in the code file, but is there another more
'official' way to do this via attributes.

The user should be able to add the control's source to a project (or
reference it in another assembly), and then select the control in the
Inheritance Picker, to create a derived class, but I want to prevent
the user from designing the base class.


I'm not quite sure I follow you. The thing is, a control can only be
designed if the source code of that control is available to the user. If
you give the user only the compiled assembly with the control in it, he
won't be able to make changes to the control.

Now, if you're giving the user the source and you assume that the user
might try to make changes to the control although you told him not to do
that, what help would an attribute be? The user could just change that
attribute or remove and design away. Not?
Oliver Sturm
--
omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog
Nov 17 '05 #3
To clarify, There are no attributes of that nature.

You can do a runtime check to see if a control is in design mode by looking
at the DesignMode property anywhere except in the constructor but that's
about it.

You can prevent a component from showing up in the toolbox by setting the
ToolboxItem attribute to False but that's not really the same either.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Tony Maresca" <to**@whereever.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Doing it with source is pointless


I wasn't asking for opinions on whether it is a
good idea, or not, to prevent a class from being
designed with attributes.

I was interested in learning if there are any
attributes that can be used to prevent a class
from being designed.

In any case, thanks for your opinion.

--
Tony M.
"Bob Powell [MVP]" <bob@_spamkiller_bobpowell.net> wrote in message
news:ek**************@tk2msftngp13.phx.gbl...
because an enterprising programmer will
just alter the source to suit his needs.

If you distribute as a DLL then the problem goes away because you can't
alter the class once it's compiled.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Tony Maresca" <to**@whereever.com> wrote in message
news:Oa**************@TK2MSFTNGP15.phx.gbl...
Hi. I have a class derived from a UserControl,
that I want to allow others to derive controls
from. I don't want them to design the base
class (which is derived from a UserControl).

I know that I can prevent the control from being
designed by making it not the first class in the
code file, but is there another more 'official' way
to do this via attributes.

The user should be able to add the control's source
to a project (or reference it in another assembly),
and then select the control in the Inheritance Picker,
to create a derived class, but I want to prevent the
user from designing the base class.

--
Tony M.


Nov 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Giovanni | last post: by
3 posts views Thread by Jeff | last post: by
1 post views Thread by =?Utf-8?B?S3lsZSBNLiBCdXJucw==?= | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by lumer26 | last post: by
reply views Thread by Vinnie | last post: by
reply views Thread by lumer26 | last post: by

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.