|
 |
pro_vb_dotnet thread: UserControl Does Not Searialise
Message #1 by steve.percival@c... on Tue, 26 Mar 2002 09:32:26
|
|
I have created the following class sub classed from
usercontrol. From the documentation I have found it should
serialise the Text property into the generated code.
unfortunately it dose not. can anyone show me the error of
my ways.
Thanks in advanced Steve.
Imports System.ComponentModel
Public Class UserControl
Inherits System.Windows.Forms.UserControl
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent()
call
End Sub
'UserControl1 overrides dispose to clean up the component
list.
Protected Overloads Overrides Sub Dispose(ByVal disposing
As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows
Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
#End Region
<Browsable(True), Description("Test"), Category
("Appearance"), DefaultValue("")> _
Public Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
MyBase.Text = Value
Me.Invalidate()
End Set
End Property
Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
Dim g As Graphics = e.Graphics
Dim fnt As Font = Me.Font
Dim Size As SizeF = g.MeasureString(Me.Text, Me.Font)
Dim posX As Integer
Dim posY As Int16
MyBase.OnPaint(e)
posX = (Me.Width - Size.Width) / 2
posY = (Me.Height - Size.Height) / 2
g.DrawString(Me.Text, fnt, New SolidBrush(Me.ForeColor),
posX, posY)
'Do Other Stuff.
End Sub
End Class
.
|
|
 |