如何从desinger中编辑属性类? [英] How do I edit class of property from the desinger ?

查看:53
本文介绍了如何从desinger中编辑属性类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个类继承自ColumnHeader



I have this class Inherited from ColumnHeader

Public Class xcolumnheader

   Inherits ColumnHeader

   <Browsable(True), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
   Public Property CP As New CollectionOfProperties

   Public Class CollectionOfProperties

       <Browsable(True)>
       Public Property Property1 As Boolean

       <Browsable(True)>
       Public Property Property2 As String

       <Browsable(True)>
       Public Property Property3 As Integer

   End Class

End Class





我希望CP属性可以从desinger中编辑(LIKE编辑控制字体)



我尝试了什么:



我试过搜索但没找到怎么做



I want the CP property to be editable from the desinger (LIKE editing font of control)

What I have tried:

I tried searching but didn't find how do to it

推荐答案

你只有将ExpandableObjectConverter作为TypeConverter添加到您的类:

You only have to add the ExpandableObjectConverter as TypeConverter to your class :
Imports System.ComponentModel

Public Class xColumnHeader
    Inherits ColumnHeader

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    Public Property CP As New CollectionOfProperties

    <TypeConverter(GetType(ExpandableObjectConverter))>
    Public Class CollectionOfProperties

        Public Property Property1 As Boolean

        Public Property Property2 As String

        Public Property Property3 As Integer

    End Class

End Class





补充:

您的属性 - 每个属性都不需要Browsable-Attribute通常总是'可浏览'。如果您希望属性不可浏览,则只需要此属性...



Additional :
You don't need the Browsable-Attribute at your Properties - each Property is normally allways 'browsable'. You only need this Attribute if you want that you Property is NOT browsable ...


这篇关于如何从desinger中编辑属性类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆