主题:急切求助:自定义控件的疑问
Imports System.Drawing.Drawing2D
Public Class ellipsectl
Inherits System.Windows.Forms.UserControl
Private type As Boolean
Public Property pmark() As Boolean
Get
Return type
End Get
Set(ByVal Value As Boolean)
type = Value
End Set
End Property
Private ptimeE As Integer
Public Property ptime() As Integer
Get
Return ptimeE
End Get
Set(ByVal Value As Integer)
ptimeE = Value
End Set
End Property
Private timeE As Integer
Public Property time() As Integer
Get
Return timeE
End Get
Set(ByVal Value As Integer)
timeE = Value
End Set
End Property
'windows 生成的代码
'画椭圆
Dim startX As Integer
Dim startY As Integer
Protected Sub ellipsectl_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim pen As New System.Drawing.Pen(System.Drawing.Color.Blue)
Dim sb As System.Drawing.Brush
sb = New SolidBrush(System.Drawing.Color.Green)
If type = True Then
e.Graphics.DrawEllipse(pen, startX, startY, Me.Width - 1, Me.Height - 1)
e.Graphics.FillEllipse(sb, New Rectangle(startX + Me.Width / 2 - 4, startY + Me.Height / 2 - 4, 8, 8))
Else
e.Graphics.DrawEllipse(pen, startX, startY, startX + Me.Width - 1, startY + Me.Height - 1)
End If
End Sub
'随时更新
Private Sub ellipsectl_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
Me.Refresh()
End Sub
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
Timer1.Interval = 1000
Me.Refresh()
End Sub
End Class
但是加载到实际的程序中时,无法像button一样定义控件数组
当 dim e as ellipsectl={ellipsectl1,ellipsectlel2,lipsectlel3,lipsectl4}时,提示错误。
Public Class ellipsectl
Inherits System.Windows.Forms.UserControl
Private type As Boolean
Public Property pmark() As Boolean
Get
Return type
End Get
Set(ByVal Value As Boolean)
type = Value
End Set
End Property
Private ptimeE As Integer
Public Property ptime() As Integer
Get
Return ptimeE
End Get
Set(ByVal Value As Integer)
ptimeE = Value
End Set
End Property
Private timeE As Integer
Public Property time() As Integer
Get
Return timeE
End Get
Set(ByVal Value As Integer)
timeE = Value
End Set
End Property
'windows 生成的代码
'画椭圆
Dim startX As Integer
Dim startY As Integer
Protected Sub ellipsectl_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim pen As New System.Drawing.Pen(System.Drawing.Color.Blue)
Dim sb As System.Drawing.Brush
sb = New SolidBrush(System.Drawing.Color.Green)
If type = True Then
e.Graphics.DrawEllipse(pen, startX, startY, Me.Width - 1, Me.Height - 1)
e.Graphics.FillEllipse(sb, New Rectangle(startX + Me.Width / 2 - 4, startY + Me.Height / 2 - 4, 8, 8))
Else
e.Graphics.DrawEllipse(pen, startX, startY, startX + Me.Width - 1, startY + Me.Height - 1)
End If
End Sub
'随时更新
Private Sub ellipsectl_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Resize
Me.Refresh()
End Sub
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
Timer1.Interval = 1000
Me.Refresh()
End Sub
End Class
但是加载到实际的程序中时,无法像button一样定义控件数组
当 dim e as ellipsectl={ellipsectl1,ellipsectlel2,lipsectlel3,lipsectl4}时,提示错误。