具有Enum

编程入门 行业动态 更新时间:2024-10-25 22:31:32
本文介绍了具有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/dotnet/faqs/?id = anytypeenums& lang = en> - MS Herfried K. Wagner MVP< URL:http://dotnet.mvps。 org /> VB< URL:http://classicvb/petition/>

There is no automatic way to do that. Creating enumerations of items with a certain arbitrary data type <URL:dotnet.mvps/dotnet/faqs/?id=anytypeenums&lang=en> -- M S Herfried K. Wagner M V P <URL:dotnet.mvps/> V B <URL:classicvb/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/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:dotnet.mvps/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/> VB< URL:http://classicvb/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:dotnet.mvps/> V B <URL:classicvb/petition/>

更多推荐

具有Enum

本文发布于:2023-11-12 05:07:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1580594.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Enum

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!