具有Enum-like IntelliSense支持的结构 [英] Structures with Enum-like IntelliSense support

查看:47
本文介绍了具有Enum-like IntelliSense支持的结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


有没有人知道如何在VS 2005中生成类似Enum的数据类型

IntelliSense?

我想要创建的是一种与枚举非常相似的类型,即

有一组固定的值,但提供了更多的方法。不幸的是,

你不能从System.Enum派生来做这件事。


我注意到如果你输入Dim C as System.Drawing.Color = ,编辑器

将显示一个颜色列表,但这实际上是ReadOnly Shared

Color结构的属性。所以必须有一种方法将结构映射

成员枚举常量...


任何想法如何做到这一点?

提前致谢!


Michael

Hello,

does anyone know how to produce a data type which offers Enum-like
IntelliSense in VS 2005?
What I am trying to create is a type which is very similar to an enum, i.e.
has a fixed set of values, but provides some more methods. Unfortunately,
you cannot derive from System.Enum to do this.

I noticed that if you type "Dim C as System.Drawing.Color = ", the editor
will display a list of colors, but this are actually ReadOnly Shared
Properties of the Color structure. So there must be a way to map structure
members to enum constants...

Any ideas how to do this?
Thanks in advance!

Michael

推荐答案

Michael,


Michael Feld < MF *** @ t-online.de> schrieb:
Michael,

"Michael Feld" <mf***@t-online.de> schrieb:
有没有人知道如何在VS 2005中生成一个类似Enum-like IntelliSense的数据类型?
[...]
我注意到如果您键入Dim C as System.Drawing.Color =,编辑器将显示颜色列表,但这实际上是ReadOnly Shared
Color结构的属性。所以必须有一种方法将结构
成员映射到枚举常量...
does anyone know how to produce a data type which offers Enum-like
IntelliSense in VS 2005?
[...]
I noticed that if you type "Dim C as System.Drawing.Color = ", the editor
will display a list of colors, but this are actually ReadOnly Shared
Properties of the Color structure. So there must be a way to map structure
members to enum constants...




没有自动的方法来做到这一点。


创建具有特定任意数据类型的项目的枚举

< URL:http://dotnet.mvps.org/dotnet/faqs/?id = anytypeenums& lang = en>


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps。 org />

VB< URL:http://classicvb.org/petition/>



There is no automatic way to do that.

Creating enumerations of items with a certain arbitrary data type
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=anytypeenums&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Hello Herfried ,


感谢快速回复!
Hello Herfried,

thanks for the quick reply!
我注意到如果你输入Dim C as System.Drawing.Color =" ;,
编辑器将显示颜色列表,但这实际上是ReadOnly
Color结构的共享属性。所以必须有一种方法将
结构成员映射到枚举常量......
没有自动的方法来做到这一点。
I noticed that if you type "Dim C as System.Drawing.Color = ", the
editor will display a list of colors, but this are actually ReadOnly
Shared Properties of the Color structure. So there must be a way to map
structure members to enum constants...
There is no automatic way to do that.




所以有什么办法可以做到这一点吗?或者是System.Color和其他人以某种方式

" hard-coded"进入VS2005智能感知器?

创建具有特定任意数据类型的项目的枚举
< URL:http://dotnet.mvps.org/dotnet/faqs/?id = anytypeenums& lang = en>



So is there any way at all to do this? Or is System.Color and others somehow
"hard-coded" into the VS2005 IntelliSense?
Creating enumerations of items with a certain arbitrary data type
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=anytypeenums&lang=en>




这也是我开始的。它工作得很好,但IDE支持缺少



我还发现了System.ComponentModel.TypeConverter.GetStandardVal ues(),

但这只适用于Windows窗体设计师,而不适用于代码

编辑器。

非常感谢,


Michael



This is what I started with too. It works well, but the IDE support is
missing.

I also discovered System.ComponentModel.TypeConverter.GetStandardVal ues(),
but this worked only for the Windows Forms designer, not for the code
editor.
Thanks anyway,

Michael


" Michael Feld" < MF *** @ t-online.de> schrieb:
"Michael Feld" <mf***@t-online.de> schrieb:
>我注意到如果你输入Dim C as System.Drawing.Color =,
>编辑器将显示颜色列表,但这实际上是ReadOnly
>颜色结构的共享属性。所以必须有一种方法来映射
> enum常量的结构成员...
> I noticed that if you type "Dim C as System.Drawing.Color = ", the
> editor will display a list of colors, but this are actually ReadOnly
> Shared Properties of the Color structure. So there must be a way to map
> structure members to enum constants...



没有自动的方法。



There is no automatic way to do that.



所以有什么办法可以做这个?或者是System.Color和其他人以某种方式硬编码。进入VS2005智能感知?



So is there any way at all to do this? Or is System.Color and others
somehow "hard-coded" into the VS2005 IntelliSense?




.NET Framework包含一个''KnownColor''枚举和颜色/对象/

''颜色''结构。你是在谈论支持

在房地产网格中?


-

MS Herfried K. Wagner

MVP< URL:http://dotnet.mvps.org/>

VB< URL:http://classicvb.org/petition/>



The .NET Framework contains a ''KnownColor'' enumeration and color /objects/
which are exposed by the ''Color'' structure. Are you talking about support
in the property grid?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


这篇关于具有Enum-like IntelliSense支持的结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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