一个能实现目的的方法
public class MyTextbox
private m_tbx as textbox
public sub new(tbxInput as textbox)
me.m_tbx=tbxInput
end sub
public property text as string
get
return me.m_tbx.text
end get
set (value as string)
me.m_tbx.text=value
end set
end property
'把你想要的数据都通过属性写出来,然后sub new时赋给它一个button实例,再把它传给propertygrid,这样就可以看到仅有的几个属性了。
to pupo:
可能我没说清楚,我所说把父类的所有属性都显示出来是指当显示该MyTextBox类实例属性时,属性表格把所有属性都显示了出来,其中有许多如cursor,righttoleft属性我并不想要它显示,有没有什么方法可以订制propertygrid所显示的属性,只让它显示我需要的几个属性呢?如果像你上面写的那样重写每个属性并设定其Browsable(False)倒是可以实现,但这样有些过于繁琐了,有没有更好的办法呢?
Public Class MyTextBox
Inherits System.Windows.Forms.TextBox
Private _myText As String
Public Property MyText() As String
Get
Return _myText
End Get
Set(ByVal Value As String)
_myText = Value
End Set
End Property
Public Sub New()
End Sub
<System.ComponentModel.Browsable(False)> _
Public Overrides Property Text() As String
Get
Return MyBase.Text
End Get
Set(ByVal Value As String)
MyBase.Text = Value
End Set
End Property
End Class