用户控件属性设计器属性

10

对于一个运行在Windows Mobile上的C# UserControl(但如果您知道完整版的Windows,请回答,它可能会起作用),如何更改在Designer属性窗口中显示的控件公共属性的内容。例如:

private Color blah = Color.Black;

public Color Blah
{
    get { return this.blah; }
    set { this.blah = value; }
}

这会在控件中显示,但它属于“Misc”类别,并且没有描述或默认值。我已经尝试使用System.ComponentModel中的设置,比如“DesignerCategory”,例如:

This shows up for the control, but it's in the "Misc" category and has no description or default value. I've tried using the settings in System.ComponentModel like "DesignerCategory", such as:
[DesignerCategory("Custom")]

但是说这仅适用于类声明...我以前使用的应该是System.ComponentModel项...

更新:

@John 说:

DesignerCatogy 用于表示类是否为窗体、组件等。

尝试这个:

[Category("Custom")]

我需要使用特定的命名空间才能获取它们吗? 我已经尝试了这些,但编译器没有识别它们。

在.NETCF中,我似乎只有从System.ComponentModel中可用的:

DataObject,
DataObjectMethod,
DefaultValue,
DesignerCategory,
DesignTimeVisible,
EditorBrowsable

它唯一不会大声呼喊的是EditorBrowsable


http://www.devx.com/dotnet/Article/32421/1763/page/2#codeitemarea - Davut Gürbüz
3个回答

6

DesignerCategory用于表示该类是否为窗体、组件等。

对于完整的Windows,您需要使用以下属性:

[System.ComponentModel.Category("Custom")]

对于描述,您可以使用[System.ComponentModel.Description("这是描述")]

要同时使用两者:

[System.ComponentModel.Category("Custom"),System.ComponentModel.Description("This is the description")]

然而,这部分内容属于system.dll,在Windows Mobile中可能会有所不同。


4

啊...这就解释了! 我同意,我不明白他怎么会认为有人在设备上设计这个...最后我检查了一下,Visual Studio没有Windows Mobile版本!肯定有其他原因,无论多么愚蠢...谢谢! - Adam Haile

0

本文并未暗示任何人正在设备上进行设计。然而,当您创建一个紧凑框架项目时,紧凑框架(适用于您的台式电脑)用于处理设计时渲染。如果您考虑一下,这是您所期望的。相同的框架(或几乎相同)用于在设计时在您的PC上进行渲染,并在运行时稍后在设备上进行渲染。问题在于,设计时属性没有添加到紧凑框架中(我认为是为了减小大小)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接