Default border on a UserControl... 
Author Message
 Default border on a UserControl...

Is there a magical way to get a border property on a UserControl or do you
need to implement it yourself?


Wed, 23 Jun 2004 03:39:33 GMT  
 Default border on a UserControl...
Hi Matt,

try the following code in your user control:

   Private m_BorderStyle As Windows.Forms.BorderStyle

   <System.ComponentModel.Category("Appearance")> _
   Public Property BorderStyle() As Windows.Forms.BorderStyle
      Get
         Return m_BorderStyle
      End Get
      Set(ByVal Value As Windows.Forms.BorderStyle)
         If Value <> m_BorderStyle Then
            m_BorderStyle = Value
            Me.RecreateHandle()
         End If
      End Set
   End Property

   Protected Overrides ReadOnly Property CreateParams() As
System.Windows.Forms.CreateParams
      Get
         Dim cp As Windows.Forms.CreateParams = MyBase.CreateParams
         Select Case m_BorderStyle
            Case BorderStyle.Fixed3D
               cp.ExStyle = cp.ExStyle Or &H200
            Case BorderStyle.FixedSingle
               cp.Style = cp.Style Or &H800000
         End Select
         Return cp
      End Get
   End Property


Quote:
> Is there a magical way to get a border property on a UserControl or do you
> need to implement it yourself?



Wed, 23 Jun 2004 04:20:38 GMT  
 Default border on a UserControl...
Bill,

Great, thanks!  That worked perfectly.



Thu, 24 Jun 2004 09:43:28 GMT  
 Default border on a UserControl...
What about if you want to create a borderstyle for .NET control that don't
have the property implemented?  Like the DateTimePicker?


Quote:
> Hi Matt,

> try the following code in your user control:

>    Private m_BorderStyle As Windows.Forms.BorderStyle

>    <System.ComponentModel.Category("Appearance")> _
>    Public Property BorderStyle() As Windows.Forms.BorderStyle
>       Get
>          Return m_BorderStyle
>       End Get
>       Set(ByVal Value As Windows.Forms.BorderStyle)
>          If Value <> m_BorderStyle Then
>             m_BorderStyle = Value
>             Me.RecreateHandle()
>          End If
>       End Set
>    End Property

>    Protected Overrides ReadOnly Property CreateParams() As
> System.Windows.Forms.CreateParams
>       Get
>          Dim cp As Windows.Forms.CreateParams = MyBase.CreateParams
>          Select Case m_BorderStyle
>             Case BorderStyle.Fixed3D
>                cp.ExStyle = cp.ExStyle Or &H200
>             Case BorderStyle.FixedSingle
>                cp.Style = cp.Style Or &H800000
>          End Select
>          Return cp
>       End Get
>    End Property



> > Is there a magical way to get a border property on a UserControl or do
you
> > need to implement it yourself?



Tue, 29 Jun 2004 06:18:21 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Usercontrol with a ToolWindow border

2. Dark border around default command button

3. Parent UserControl's Properties in a UserControl (placed on another UserControl)

4. how to default .Text property ofa usercontrol?

5. Hiding UserControl default properties

6. UserControl default size?

7. Can't make button default in usercontrol

8. MSHTML - showing borders of tables with border=0 in design mode

9. How to make the button in Usercontrol call Usercontrol's Click event

10. Usercontrol as row (usercontrol datagrid) !!

11. Accessing a Usercontrol within a Usercontrol

12. Drag from UserControl to another usercontrol

 

 
Powered by phpBB® Forum Software