AddCategory Method
Description
Adds a new category to the Property Grid control.
Syntax
Public Function AddCategory( _
ByVal Title As String _
) As PropertyGridItem
Parameters
- Title: The caption/title of the category.
Return Type
Reference to the new PropertyGridItem.
Remarks
Categories are used to group PropertyGridItems into groups within the PropertyGrid. By default, the background color of categories is displayed in a different color than normal items. Categories have an expand/collapse button that can be used to show/hide the PropertyGridItems that belong to the category.
Example
Adding a Category to the PropertyGrid (Visual Basic)
This sample illustrates how to add a category to the PropertyGrid.
Dim Category As PropertyGridItem
' Adds a Category to the PropertyGrid titled "Vehicle"
Set Category = wndPropertyGrid.AddCategory("Vehicle")
' Adds a PropertyGridItem of type String titled "Manufacturer" with a value of "XYZ Company" to
'the "Vehicle" category
Category.AddChildItem PropertyItemString, "Manufacturer", "XYZ Company"
' Adds a PropertyGridItem of type Number titled "Year" with a value of "2004" to
'the "Vehicle" category
Category.AddChildItem PropertyItemNumber, "Year", "2004"
' Adds a PropertyGridItem of type Color titled "Color" with a value of "vbGreen" to
'the "Vehicle" category
Category.AddChildItem PropertyItemColor, "Color", vbGreen
' Adds a Category to the PropertyGrid titled "Customer"
Set Category = wndPropertyGrid.AddCategory("Customer")
' Adds a PropertyGridItem of type String titled "Name" with a value of "John Doe" to
'the "Customer" category
Category.AddChildItem PropertyItemString, "Name", "John Doe"
' Adds a PropertyGridItem of type Number titled "Age" with a value of "34" to
'the "Customer" category
Category.AddChildItem PropertyItemNumber, "Age", "34"
See Also
Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.