集团在自定义的控件属性
问题说明
在我们的IDE,比如,Visual Studio中,如果我们显示System.Windows.Forms.Button控件的属性,我们可以看到一些属性,揭露anoter的属性集。例如: FlatAppearance,字体,位置,保证金的,等等
In our IDE, for example, Visual Studio, if we display the properties of a System.Windows.Forms.Button control, we see some properties that expose anoter set of properties. For example: FlatAppearance, Font, Location, Margin, etcetera.
我希望做一个自定义的控制类似的东西。
I would like to do something similar in a custom control.
我知道code的背后是错误,但这里是什么I'm试图做一个例子:
I know the code behind is wrong, but here is an example of what I´m trying to do:
Public Class StateOfMyCustomControl
Public Enum EnumVisibility
Visible
NonVisible
End Enum
Public Enum EnumEventManagement
Automatic
Manual
End Enum
Private mAssociatedControl As MyCustomControl
Private mVisibility As EnumVisibility
Private mEventManagement As EnumEventManagement
Public Sub New(ByVal AssociatedControl As MyCustomControl)
mAssociatedControl = AssociatedControl
End Sub
Public Property Visibility() As EnumVisibility
Get
Return mVisibility
End Get
Set(ByVal value As EnumVisibility)
mVisibility = value
mAssociatedControl.Visible = False
If mVisibility = EnumVisibility.Visible Then
mAssociatedControl.Visible = True
End If
End Set
End Property
Public Property EventManagement() As EnumEventManagement
Get
Return mEventManagement
End Get
Set(ByVal value As EnumEventManagement)
mEventManagement = value
End Set
End Property
End Class
Public Class MyCustomControl
' ...
Private mState As StateOfMyCustomControl
Public Sub New()
mState = New StateOfMyCustomControl(Me)
End Sub
Public Property State() As StateOfMyCustomControl
Get
Return mState
End Get
Set(ByVal value As StateOfMyCustomControl)
mState = value
End Set
End Property
' ...
End Class
在我的IDE,在我的自定义控件的属性窗口,我想看看我的财产的国家的,以显示它的可能性来设置属性的能见度的和 EventManagement 的。
In my IDE, in the properties window of my custom control, I would like to see my property State, with the possibility of display it to set the properties Visibility and EventManagement.
非常感谢
正确答案
您需要告诉它使用 ExpandableObjectConverter
(或自定义转换器)的 StateOfMyCustomControl
。在C#中,这就是:
You need to tell it to use ExpandableObjectConverter
(or a custom converter) for StateOfMyCustomControl
. In C#, this is:
[TypeConverter(typeof(ExpandableObjectConverter))]
public class StateOfMyCustomControl {...}
不过你申请的属性在VB中,做到这一点;-p
However you apply attributes in VB, do that ;-p
可能:
<TypeConverter(GetType(ExpandableObjectConverter))> _
Public Class StateOfMyCustomControl
...
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tangkajbj
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20 -
希伯来语的空格句子标记化错误
it1352 06-22