新手入门:自定义的控件开发的一个错误,请教高手!
源代码如下:
Public Class DropPanel
Inherits System.Windows.Forms.Panel
Private iImageType As Integer
Private iPanelHeight As Integer
Private strLabelString As String = "New Label "
Public Property LabelString() As String
Get
Return strLabelString
End Get
Set(ByVal value As String)
strLabelString = value
Invalidate()
End Set
End Property
Private Sub DropPanel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
错误提示:
Base class 'System.Windows.Forms.Panel ' specified for class 'DropPanel ' cannot be different from the base class 'System.Windows.Forms.UserControl ' of one of its other partial types.
哪位大侠能帮我看看
[解决办法]
Base class 'System.Windows.Forms.Panel ' specified for class 'DropPanel ' cannot be different from the base class 'System.Windows.Forms.UserControl ' of one of its other partial types.
像这种你不能用用UserControl的,因为你继承的是Panel,也不是From,你要用Component去创建,不要用User Control,(或是你用一个普通的Class去创建就行了),UserControl是具有设计时UI的,.Net会自动产生一些代码。而Component就不会了。