PropertyTab Class
Provides a base class for property tabs.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
System.Windows.Forms.Design::PropertyTab
System.Windows.Forms.Design::EventsTab
System.Windows.Forms.PropertyGridInternal::PropertiesTab
| Name | Description | |
|---|---|---|
![]() | PropertyTab() | Initializes a new instance of the PropertyTab class. |
| Name | Description | |
|---|---|---|
![]() | Bitmap | Gets the bitmap that is displayed for the PropertyTab. |
![]() | Components | Gets or sets the array of components the property tab is associated with. |
![]() | HelpKeyword | Gets the Help keyword that is to be associated with this tab. |
![]() | TabName | Gets the name for the property tab. |
| Name | Description | |
|---|---|---|
![]() | CanExtend(Object^) | Gets a value indicating whether this PropertyTab can display properties for the specified component. |
![]() | Dispose() | Releases all the resources used by the PropertyTab. |
![]() | Dispose(Boolean) | Releases the unmanaged resources used by the PropertyTab and optionally releases the managed resources. |
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows a PropertyTab to attempt to free resources and perform other cleanup operations before the PropertyTab is reclaimed by garbage collection.(Overrides Object::Finalize().) |
![]() | GetDefaultProperty(Object^) | Gets the default property of the specified component. |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetProperties(ITypeDescriptorContext^, Object^, array<Attribute^>^) | Gets the properties of the specified component that match the specified attributes and context. |
![]() | GetProperties(Object^) | Gets the properties of the specified component. |
![]() | GetProperties(Object^, array<Attribute^>^) | Gets the properties of the specified component that match the specified attributes. |
![]() | GetType() | |
![]() | MemberwiseClone() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
The PropertyTab class provides the base class behavior for a property tab. Property tabs are displayed on the toolbar of the PropertyGrid control of the Properties window, and allow a component to display different views of its properties or other data.
User code will usually not create an instance of a PropertyTab directly. Instead, a PropertyTabAttribute that indicates the type of the property tab or property tabs to display for a component can be associated with the properties or types that the PropertyTab should be displayed for.
The PropertyGrid will instantiate a PropertyTab of the type specified by a PropertyTabAttribute associated with the type or property field of the component that is being browsed.
The following code example provides an example PropertyTab that lists any properties on a component, arranged by type name.
#using <System.Windows.Forms.dll> #using <System.Drawing.dll> #using <System.dll> using namespace System; using namespace System::ComponentModel; using namespace System::ComponentModel::Design; using namespace System::Drawing; using namespace System::IO; using namespace System::Reflection; using namespace System::Runtime::Serialization; using namespace System::Runtime::Serialization::Formatters::Binary; using namespace System::Windows::Forms; using namespace System::Windows::Forms::Design; using namespace System::Security::Permissions; namespace TypeCategoryTabExample { ref class TypeCategoryTab; // forward declaration. // This component adds a TypeCategoryTab to the propery browser // that is available for any components in the current design mode document. [PropertyTabAttribute(TypeCategoryTabExample::TypeCategoryTab::typeid,PropertyTabScope::Document)] public ref class TypeCategoryTabComponent: public System::ComponentModel::Component { public: TypeCategoryTabComponent(){} }; // A TypeCategoryTab property tab lists properties by the // category of the type of each property. public ref class TypeCategoryTab: public PropertyTab { private: // This String^ contains a Base-64 encoded and serialized example property tab image. [BrowsableAttribute(true)] String^ img; public: TypeCategoryTab() { img = "AAEAAAD/////AQAAAAAAAAAMAgAAAFRTeXN0ZW0uRHJhd2luZywgVmVyc2lvbj0xLjAuMzMwMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAABVTeXN0ZW0uRHJhd2luZy5CaXRtYXABAAAABERhdGEHAgIAAAAJAwAAAA8DAAAA9gAAAAJCTfYAAAAAAAAANgAAACgAAAAIAAAACAAAAAEAGAAAAAAAAAAAAMQOAADEDgAAAAAAAAAAAAD///////////////////////////////////9ZgABZgADzPz/zPz/zPz9AgP//////////gAD/gAD/AAD/AAD/AACKyub///////+AAACAAAAAAP8AAP8AAP9AgP////////9ZgABZgABz13hz13hz13hAgP//////////gAD/gACA/wCA/wCA/wAA//////////+AAACAAAAAAP8AAP8AAP9AgP////////////////////////////////////8L"; } // Returns the properties of the specified component extended with // a CategoryAttribute reflecting the name of the type of the property. [ReflectionPermission(SecurityAction::Demand, Flags=ReflectionPermissionFlag::MemberAccess)] virtual System::ComponentModel::PropertyDescriptorCollection^ GetProperties( Object^ component, array<System::Attribute^>^attributes ) override { PropertyDescriptorCollection^ props; if ( attributes == nullptr ) props = TypeDescriptor::GetProperties( component ); else props = TypeDescriptor::GetProperties( component, attributes ); array<PropertyDescriptor^>^propArray = gcnew array<PropertyDescriptor^>(props->Count); for ( int i = 0; i < props->Count; i++ ) { // Create a new PropertyDescriptor from the old one, with // a CategoryAttribute matching the name of the type. array<Attribute^>^temp0 = {gcnew CategoryAttribute( props[ i ]->PropertyType->Name )}; propArray[ i ] = TypeDescriptor::CreateProperty( props[ i ]->ComponentType, props[ i ], temp0 ); } return gcnew PropertyDescriptorCollection( propArray ); } virtual System::ComponentModel::PropertyDescriptorCollection^ GetProperties( Object^ component ) override { return this->GetProperties( component, nullptr ); } property String^ TabName { // Provides the name for the property tab. virtual String^ get() override { return "Properties by Type"; } } property System::Drawing::Bitmap^ Bitmap { // Provides an image for the property tab. virtual System::Drawing::Bitmap^ get() override { System::Drawing::Bitmap^ bmp = gcnew System::Drawing::Bitmap( DeserializeFromBase64Text( img ) ); return bmp; } } private: // This method can be used to retrieve an Image from a block of Base64-encoded text. Image^ DeserializeFromBase64Text( String^ text ) { Image^ img = nullptr; array<Byte>^memBytes = Convert::FromBase64String( text ); IFormatter^ formatter = gcnew BinaryFormatter; MemoryStream^ stream = gcnew MemoryStream( memBytes ); img = dynamic_cast<Image^>(formatter->Deserialize( stream )); stream->Close(); return img; } }; }
for full access to system resources. Demand value: InheritanceDemand. Associated state:
Available since 1.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


