Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / August 2006

Tip: Looking for answers? Try searching our database.

Component shows up as being private

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
wolfmail@writeme.com - 15 Jun 2006 07:26 GMT
Hello all,

I have created a custom component to implement our business objects.
I'm able to drag a BO into my designer from the toolbar and can then
use it for databinding etc.

Unfortunately when looking at the generated code for the declaration of
the added component, i find the declaration as being private. When i'm
using other components (for example a Dataset) it is being generated as
"friend".

Can anybody tell me what to do to let the designer generate code for my
component declaration with an access modifier other than private.

My component uses the following interfaces and inheritance:
Public Class myComponent
       Inherits Component
       Implements IEnumerable
       Implements ICustomTypeDescriptor
       Implements ITypedList
...
End Class

I hope somebody can tell me what modification to make to set the access
modifier to the correct setting.

Eric
Dave Sexton - 21 Jun 2006 23:32 GMT
Hi Wolfmail,

really?

In C#, dragging a DataSet onto a Form, or any IComponent for that matter,
always sets the modifier to private by default.  I can't see why "Friend"
should be the default for a DataSet.

The user can always select the component on the designer and use the
property grid to change the access modifier at design-time if they wish.

HTH

> Hello all,
>
[quoted text clipped - 23 lines]
>
> Eric
Vladimir Khvostov - 16 Aug 2006 06:19 GMT
Here is a Component Designer that would set access modifier to internal (C#)
for newly added components:

   class DemoComponentDesigner : ComponentDesigner
   {
       protected override void
PostFilterProperties(System.Collections.IDictionary properties)
       {
           base.PostFilterProperties(properties);
           modifiersPropertyDescriptor =
(PropertyDescriptor)properties["Modifiers"];
       }

       public override void
InitializeNewComponent(System.Collections.IDictionary defaultValues)
       {
           base.InitializeNewComponent(defaultValues);
           modifiersPropertyDescriptor.SetValue(Component,
System.CodeDom.MemberAttributes.Assembly);
       }

       PropertyDescriptor modifiersPropertyDescriptor;
   }

To associate this designer with your component add Designer attribute to
your component:
   [Designer(typeof(DemoComponentDesigner))]
   public partial class DemoComponent : Component
   {
    ...
   }

Good luck,
-- Vladimir Khvostov

> Hello all,
>
[quoted text clipped - 23 lines]
>
> Eric

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.