如何在没有继承属性的情况下在设计时填充列表?

时间:2018-06-14 18:42:44

标签: c# vb.net

我有这样的控件:

Class TextBoxEx
    Inherits TextBox
    Public Property MyCustomProperty As String
End Class

这样的组件:

Class Config
    Inherits Component
    Private _Controls As List(Of TextBoxEx)
    Public Property Controls As List(Of TextBoxEx)
        Get
            Return _Controls
        End Get
        Set(value As List(Of TextBoxEx))
            _Controls = value
        End Set
    End Property
End Class

因此,在将此组件放在表单上之后,我想在设计器中填充此列表,我还希望只查看TextBoxEx控件的属性MyCustomProperty,而不是TextBox的所有属性。

C#代码:

class TextBoxEx : TextBox
{
    public string MyCustomProperty { get; set; }
}

class Config : Component
{
    private List<TextBoxEx> _Controls;
    public List<TextBoxEx> Controls
    {
        get
        {
            return _Controls;
        }
        set
        {
            _Controls = value;
        }
    }
}
有人帮帮我

0 个答案:

没有答案
相关问题