1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
Imports System.Drawing.Drawing2D
Public Class UserControl1
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
Dim bord As Rectangle = Me.ClientRectangle
bord.Inflate(-1, -1)
Dim p1, p2, p3, p4 As Point
p1 = New Point(bord.Left, bord.Top)
p2 = New Point(bord.Right, bord.Top)
p3 = New Point(bord.Right, bord.Bottom)
p4 = New Point(bord.Left, bord.Bottom)
Dim gr As Graphics = e.Graphics
Dim pp As New Pen(Brushes.SlateGray)
If ShowBorderTop Then
gr.DrawLine(pp, p1, p2)
End If
If ShowBorderRight Then
gr.DrawLine(pp, p2, p3)
End If
If ShowBorderBottom Then
gr.DrawLine(pp, p3, p4)
End If
If ShowBorderLeft Then
gr.DrawLine(pp, p4, p1)
End If
If Text IsNot Nothing Then
gr.DrawString(Text, New Font(FontFamily.GenericSansSerif, 8), Brushes.Black, ClientRectangle)
End If
End Sub
Public Sub New()
' Cet appel est requis par le concepteur.
InitializeComponent()
' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
Me.Text = "my control"
SetStyle(ControlStyles.ResizeRedraw, True)
End Sub
Private m_brTop As Boolean
Public Property ShowBorderTop As Boolean
Get
Return m_brTop
End Get
Set(ByVal value As Boolean)
m_brTop = value
Me.Invalidate()
End Set
End Property
Private m_brLeft As Boolean
Public Property ShowBorderLeft As Boolean
Get
Return m_brLeft
End Get
Set(ByVal value As Boolean)
m_brLeft = value
Me.Invalidate()
End Set
End Property
Private m_brRight As Boolean
Public Property ShowBorderRight As Boolean
Get
Return m_brRight
End Get
Set(ByVal value As Boolean)
m_brRight = value
Me.Invalidate()
End Set
End Property
Private m_brBottom As Boolean
Public Property ShowBorderBottom As Boolean
Get
Return m_brBottom
End Get
Set(ByVal value As Boolean)
m_brBottom = value
Me.Invalidate()
End Set
End Property
End Class |
Partager