重新创建“字体”财产行为
从 System.Web.UI.WebControls.WebControl
继承的控件有一个名为 Font
的属性。类型为System.Web.Ui.WebControls.FontInfo
。
在设计器中使用这些控件时,它将 Font
属性分解为多个属性,例如 Font-Bold
、Font-Italic
等。在代码隐藏中使用这些相同的 WebControl 时,只有 Font
属性(没有 Font-Bold
、Font-Italic
等)。
创建 WebControl 时如何手动重新创建此行为?具体来说,System.ComponentModel
属性的什么组合可以在 Intellisense 中显示/隐藏这些属性?
Controls that inherit off of System.Web.UI.WebControls.WebControl
have a property called Font
. The type is System.Web.Ui.WebControls.FontInfo
.
When working with these controls in the designer, it breaks out the Font
property into multiple properties like Font-Bold
, Font-Italic
, etc. When working with these same WebControls in the codebehind, there's only a Font
property (no Font-Bold
, Font-Italic
, etc).
How can this behavior be manually recreated when creating WebControls? Specifically, what combination of System.ComponentModel
attributes can show/hide these properties in Intellisense?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该能够以布尔属性的形式访问粗体、斜体等:
http://msdn.microsoft.com/it-it/library/system.web.ui.webcontrols.fontinfo.aspx
You should be able to access Bold, Italic and so on as boolean properties:
http://msdn.microsoft.com/it-it/library/system.web.ui.webcontrols.fontinfo.aspx
财产崩溃是自动发生的。
如果您的控件具有自己的属性,
则可以在 aspx 中使用 Font-Bold 语法,这意味着它将
按预期工作。但是,自动完成不起作用,并且我不确定需要哪种
System.ComponentModel
属性组合才能使其表现得像 Font-Bold。The property-breakdown is happening automatically.
If you have a control that has a property that has properties of its own
you can use the Font-Bold syntax in the aspx, meaning that
will work as expected. However, autocomplete does not work, and I'm not sure which combination of
System.ComponentModel
attributes is required to make it behave like the Font-Bold.您要扩展的属性(本例中为
Font
)应将属性System.ComponentModel.DesignerSerializationVisibility
设置为System.ComponentModel.DesignerSerializationVisibility.Content< /代码>。以下链接详细介绍了
System.ComponentModel.DesignerSerializationVisibility
The property that you'd like to expand (
Font
in this case) should have attributeSystem.ComponentModel.DesignerSerializationVisibility
set toSystem.ComponentModel.DesignerSerializationVisibility.Content
. This is detailed in the following linkSystem.ComponentModel.DesignerSerializationVisibility