2010-09-30 183 views
9

如何爲我的房產添加文字說明?添加房地產描述

alt text

我的代碼:

private bool _SpaceKey; 

public bool SpaceKey 
{ 
    get 
    { 
     return _SpaceKey; 
    } 
    set 
    { 
     _SpaceKey = value; 
    } 
} 
+1

請指定您的語言,並直接在問題中包含任何需要的圖片。 – 2010-09-30 16:41:18

回答

22

看一看的Description Attribute

[Description("This is the description for SpaceKey")] 
public bool SpaceKey { get; set; } 

你還可以使用Category Attribute指定屬性的類別:

[Category("Misc")] 
[Description("This is the description for SpaceKey")] 
public bool SpaceKey { get; set; } 
7

如果要在Visual Studio設計器(或任何其他兼容的IDE)中查看描述,則需要使用design-time attributes for components,它們在System.ComponentModel命名空間中定義。

[Description("This is the description of Space Key.")] 
public bool SpaceKey { get; set; } 

在這樣做之前,請考慮學習如何從類庫中的描述中編寫好的描述(儘管它們並不總是有幫助)。遵循現有的風格是很好的。

如果你想看到的代碼提示,像提示選擇與智能感知成員時,你也需要使用XML comments的文檔:

/// <summary> 
/// Gets or sets space key (that would probably make a bad summary). 
/// </summary> 
public bool SpaceKey { get; set; } 

就是這樣。

+0

當僅使用[描述]時,顯示智能感知文本描述 – 2014-12-10 13:13:10

+0

智能感知是否顯示可能取決於您的Visual Studio版本。我使用的是VS 2013,而[描述]不會在代碼中顯示幫助文本,而XML標籤會顯示幫助文本。 – Aeroradish 2015-09-11 13:34:31

1

(有點晚,但也許有幫助的人)

,您可以使用另一種方法是:

[Browsable(true)] 

如果Browsabletrue,你可以看到在屬性窗口和當地產的false,沒有人不能通過設計器中的Property Window來改變它。 關於這個,請參見more information