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