在设计时显示枚举值的自定义工具提示? [英] Show a custom tooltip for an enumeration value at design time?
本文介绍了在设计时显示枚举值的自定义工具提示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在DLL中,我有以下枚举。
In a DLL I have the following enumeration.
/// <summary>
///
/// </summary>
public enum Shapes
{
/// <summary>
///
/// </summary>
[DescriptionAttribute("A shape with 1 continuous edge that has no corners.")]
Circle,
/// <summary>
///
/// </summary>
[DescriptionAttribute("A shape 4 equal sides with 4 90° corners.")]
Square,
/// <summary>
///
/// </summary>
[DescriptionAttribute("A shape 2 pairs of sides that are unequal with 4 90° corners.")]
Rectangle,
}
如何在VS内的设计时将DescriptionAttribute文本显示在工具提示中而不是Shape.Circle = 0?
谢谢
我尝试了什么:
我还没找到任何在线解决方案。
How do I get the DescriptionAttribute text to appear in the tooltip instead of the Shape.Circle = 0 at design time within VS?
Thanks
What I have tried:
I haven't found any solutions online yet.
推荐答案
你没有指定平台(WinForms,WPF或MVC)......
乍一看,我会创建一个Shape对象列表:
You didn't specify the platform (WinForms, WPF, or MVC)...
At first blush, I would create a list of Shape objects:
public class MyShape
{
public ShapeEnum Value { get; set; }
public string Name { get { return this.Value.ToString(); } }
public string Description {get; set; }
}
public ListOfShapes:List<MyShape>{}
然后在静态类中实例化它:
And then instantiate it in a static class:
public static Globals
{
public static ListOfShapes Shapes = null;
static Globals()
{
Shapes = new ListOfShapes(){ new MyShape(){Value=ShapeEnum.Circle, Description = "circle description"},...};
}
}
将您的控件绑定到该列表。
Bind your control to that list.
在编译至少六次之后,XML摘要标记最终出现在工具提示中。
谢谢,
After compiling at least a half dozen times, the XML summary tag is finally appearing with the tooltip.
Thanks,
/// <summary>
///
/// </summary>
public enum Shapes
{
/// <summary>
/// "A shape with a continuous edge and has no corners."
/// </summary>
[DescriptionAttribute("A shape with a continuous edge and has no corners.")]
//[EnumToClass(typeof(Circle))]
Circle,
/// <summary>
/// "A shape 4 equal side with 4 90° corners."
/// </summary>
[DescriptionAttribute("A shape 4 equal side with 4 90° corners.")]
//[EnumToClass(typeof(Square))]
Square,
/// <summary>
/// "A shape 2 pairs of side that are unequal with 4 90° corners."
/// </summary>
[DescriptionAttribute("A shape 2 pairs of side that are unequal with 4 90° corners.")]
//[EnumToClass(typeof(Rectangle))]
Rectangle,
}
Outlaw,我会给你答案。
Outlaw, I'll give you the answer to you.
这篇关于在设计时显示枚举值的自定义工具提示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文