枚举类型的 UserControl 属性在设计器中显示为 bool 或根本不显示 [英] UserControl Property of type Enum displays in designer as bool or not at all

查看:50
本文介绍了枚举类型的 UserControl 属性在设计器中显示为 bool 或根本不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有多个公共属性的用户控件.这些属性会自动显示在 VS2005 设计器的其他"类别下的属性窗口中.除了作为枚举的两个属性没有正确显示.

I have a usercontrol that has several public properties. These properties automatically show up in the properties window of the VS2005 designer under the "Misc" category. Except two of the properties which are enumerations don't show up correctly.

第一个使用以下枚举:

public enum VerticalControlAlign
{
    Center,
    Top,
    Bottom
}

这在设计器中根本不显示.

第二个使用这个枚举:

public enum AutoSizeMode
{
    None,
    KeepInControl
}

这个出现了,但是设计师好像觉得是bool,只显示True和False.当您使用控件构建项目时,它会说它无法将类型 bool 转换为 AutoSizeMode.

This one shows up, but the designer seems to think it's a bool and only shows True and False. And when you build a project using the controls it will say that it can't convert type bool to AutoSizeMode.

此外,这些枚举被全局声明到命名空间,因此它们可以在任何地方访问.

Also, these enums are declared globably to the Namespace, so they are accessible everywhere.

有什么想法吗?

推荐答案

对于初学者来说,第二个枚举 AutoSizeMode 在 System.Windows.Forms 中声明.所以这可能会给设计者带来一些问题.

For starters, the second enum, AutoSizeMode is declared in System.Windows.Forms. So that might cause the designer some issues.

其次,您可能会发现 MSDN 上的以下页面很有用:

Secondly, you might find the following page on MSDN useful:

http://msdn.microsoft.com/en-us/library/tk67c2t8.aspx

这篇关于枚举类型的 UserControl 属性在设计器中显示为 bool 或根本不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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