2008-09-16 33 views
6

Tôi có một UserControl trong dự án Asp.net của tôi có thuộc tính công khai. Tôi không muốn thuộc tính này hiển thị trong Cửa sổ thuộc tính Visual Studio khi người dùng làm nổi bật một cá thể của UserControl trong IDE. Tôi nên sử dụng thuộc tính nào (hoặc phương pháp khác) để ngăn chặn nó hiển thị?Đặt thuộc tính UserControl để không hiển thị trong cửa sổ thuộc tính VS

class MyControl : System.Web.UI.UserControl { 
    // Attribute to prevent property from showing in VS Property Window? 
    public bool SampleProperty { get; set; } 

    // other stuff 
} 

Trả lời

11

Sử dụng các thuộc tính sau ...

using System.ComponentModel; 

[Browsable(false)] 
public bool SampleProperty { get; set; } 

Trong VB.net, will be này:

<System.ComponentModel.Browsable(False)> 
3

Tons of attributes ra khỏi đó để kiểm soát như thế nào PropertyGrid hoạt động.

[Browsable(false)] 
public bool HiddenProperty {get;set;} 
2

Sử dụng các thuộc tính System.ComponentModel.Browsable để

hoặc

// C# 
    [System.ComponentModel.Browsable(false)] 
Các vấn đề liên quan