我已经测试了很多遍,也试了继承imagebutton,然后新加一个属性
Private mOnMouseImageURL As String
<NotifyParentProperty(True), Category("Appearance"), DefaultValue(""), _
Editor("System.Web.UI.Design.ImageUrlEditor, System.Design", _
GetType(UITypeEditor)), Bindable(True)> _
Public Property OnMouseImageURL() As String
Get
Return mOnMouseImageURL
End Get
Set(ByVal Value As String)
mOnMouseImageURL = Value
End Set
End Property
Private conSubButton1 As ImageButton
属性定义
<DesignerSerializationVisibility(DesignerSerializationVisibility.Content), _
NotifyParentProperty(True), PersistenceMode(PersistenceMode.InnerProperty), _
Category("ChildControl"), Description("ImageButton")> _
Public ReadOnly Property subImageButton1() As ImageButton
Get
Me.EnsureChildControls()
Return conSubButton1
End Get
End Property
创建子控件:
Protected Overrides Sub CreateChildControls()
If conSubButton1 Is Nothing Then
conSubButton1 = New ImageButton
End If
MyBase.Controls.Add(mhtmlTable)
End Sub