Danpe
Danpe

Reputation: 19057

Add Properties to a base class so they show on Visual Studio's Properties window?

I have this class:

public class CameraWindow : PictureBox

How can i add a property that will show up here:

enter image description here

It's prolly really easy but i cant find a way of doing that =\

Upvotes: 0

Views: 426

Answers (3)

adrianbanks
adrianbanks

Reputation: 83014

You need to annotate the property with the Browsable attribute.

e.g.

public class CameraWindow : PictureBox
{
    [Browsable(true)]
    public int MyProperty{get;set;}
}

You can also add a Category attribute if you want your property to appear in a specific grouping in the properties window.

Upvotes: 3

Bobby
Bobby

Reputation: 1604

using System.ComponentModel;

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

Upvotes: 1

Stephan Bauer
Stephan Bauer

Reputation: 9249

You can make use of the BrowsableAttribute

Upvotes: 1

Related Questions