473,624 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1688
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******** ******@TK2MSFTN GP15.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******** ********@TK2MSF TNGP12.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@_spamkille r_bobpowell.net > wrote in message
news:ek******** ******@tk2msftn gp13.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******** ******@TK2MSFTN GP15.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1990
by: SB | last post by:
What is the best way to prevent an object from being moved by the garbage collector (for the lifetime of an application)? Pinning seems to be designed for temporary operations...so I guess that's not an option. The reason I'm ask is because I have a class that contains many delegates that are used as callback functions to a C dll. The dll may call any one of these delegates at any time...so their addresses must be set in stone until...
4
1137
by: BluDog | last post by:
Hi I have a basic UserControl that i want to be able to prevent controls being added to, i was thinking about catching the ControlAdded event and then removing the control immediatley after, but was wondering if there was a better approach. Cheers Blu
7
3795
by: Alon | last post by:
Hi, I'm making my own control which holds some buttons ant textboxes and also has a panel control. in design time i want to drop another controls into the panel that is in my usercontrol. the problem is that the added controls are added to the usercontrol and not to the panel... 10X,
7
2632
by: Sharon | last post by:
I'm writing my own control that derived from the UserControl. In my control I have some public properties (with get and set) that I do not want them to be shown on the designer properties window and I also do not want the Windows Form Designer to generate code automatically on the user Form for them. To block the properties from being shown on the designer properties window I use: public int MyProp
7
8816
by: Fabio Cannizzo | last post by:
How can I prevent a few lines of code contained in the constructor of a Form from being executed by the Designer? Thanks, Fabio
5
3391
by: EqDev | last post by:
I have a class that is a control derived from UserControl. I want to use serialization and deserialization with this calss but I get an exception "Cannot serialize member System.ComponentModel.Component.Site of type System.ComponentModel.ISite because it is an interface.". I am not interested in serializing any member from the base class only the properties in the derived class. How can I prevent the entire base class from being...
1
3236
by: Giovanni | last post by:
Dear Friends/Gurus, I have exhausted myself and have yet no solution to the following: I have an ASP.NET 2.0 Survey type application. On a page, I have placed a GridView which is bound to an SQLDataSource. The GridView contains 3 columns: QuestionNumber, QuestionText, and a TemplateField. Each row in the GridView represents a question in a table (Ex.: "18. Satisfaction Level").
3
3036
by: Jeff | last post by:
Hey ASP.NET 2.0 This the ObjectDataSource in my UserControl, <asp:ObjectDataSource ID="odsMessage" runat="server" SelectMethod="ExecuteMessage" TypeName="AH.MyNetwork.BLL.Network.Message"> <SelectParameters> <asp:ProfileParameter Name="user" PropertyName="UserName"
1
18819
by: =?Utf-8?B?S3lsZSBNLiBCdXJucw==?= | last post by:
I have a set of controls and logic that must be invoked from several pages within a web application as a popup dialog, so I intend to use a userControl contained in a panel extended with the modalPopupExtender to get this behavior. I want to deal with showing and hiding the popup in server-side code, so I've set the TargetControlID to a hidden (style=display:none;) button and not set the OkButton or CancelButton. The userControl has...
0
8238
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
8174
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
8680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8624
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
6111
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
5565
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();...
0
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1786
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1485
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.