Hi,
I have a user control who's class starts like this
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.ComponentModel
<ToolboxBitmap(GetType(Windows.Forms.Panel)), Category("test")> _
Public Class dialogTopBar
Inherits System.Windows.Forms.UserControl
what I want to do is set the dock property's default value to top so when
its added to the form it automatically docks to the top dock location, how
would I go about doing that in this declaration? thanks
Andy Becker - 17 Aug 2004 16:44 GMT
> Hi,
>
[quoted text clipped - 15 lines]
> its added to the form it automatically docks to the top dock location, how
> would I go about doing that in this declaration? thanks
You will need a custom designer, and in the OnSetComponentDefaults override,
do something like:
MyBase.Control.Dock = ...
Let me know if you need more info on custom designers. Meantime, a look at
DesignerAttribute should point you the right direction to get going.
Best Regards,
Andy
"Peter Huang" - 18 Aug 2004 07:04 GMT
Hi Brian,
I agree with Andy's suggestion, here goes the code.
<DesignerAttribute(GetType(TestControlDesigner))> _
Public Class UserControl1
Inherits System.Windows.Forms.UserControl
'........ omit the generated code
End Class
Public Class TestControlDesigner
Inherits System.Windows.Forms.Design.ControlDesigner
Public Overrides Sub OnSetComponentDefaults()
MyBase.Control.Dock = DockStyle.Top
End Sub
End Class
You may also take a look at the ControlDesigner Class.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwindowsformsdesigncontroldesignerclasstopic.asp
Best regards,
Peter Huang
Microsoft Online Partner Support

Signature
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Brian Henry - 18 Aug 2004 13:59 GMT
i cant get the designerattribute property to show up... even with importing
all these...
Imports System
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Collections
Imports System.Drawing
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.Windows.Forms.Design
> Hi Brian,
>
[quoted text clipped - 26 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Andy Becker - 18 Aug 2004 16:39 GMT
> i cant get the designerattribute property to show up... even with importing
> all these...
Oops, that is a confusing part about attributes. You don't acually use
include "Attribute". Try this:
System.ComponentModel.Designer(GetType(...
Best Regards,
Andy
Brian Henry - 18 Aug 2004 18:40 GMT
Dennis - 30 Oct 2004 22:33 GMT
When I follow the example in the MDSN on DesignerAttrributes, for the statement
Inherits System.Windows.Forms.Design.ControlDesigner
I get an error saying that the type is not defined. I copied all the
imports and other parts directly from the MSDN using cut and paste. Any idea
what's going on?
> > i cant get the designerattribute property to show up... even with
> importing
[quoted text clipped - 8 lines]
>
> Andy