Skip to content

Add Method

Description

Adds a constraint to the property grid item's collection of constraints.

Syntax

Public Sub Add( _
    ByVal [Constraint](#) As String, _
    Optional ByVal [Data](#) As Variant _
)

Parameters

  • Constraint: The constraint which is to be added.
  • Data: Variant data value associated with this constraint. This allows many different data types to be associated with the constraint item.

Remarks

The constraints added to a PropertyGridItem can be viewed and selected by a drop-down combo list if the combo button style has been applied to the PropertyGridItem. If no combo button is present, the constraint items can be seen by double-clicking the PropertyGridItem or by pressing the Up and Down arrow keys when the PropertyGridItem has focus.

Example

Adding Constraints to a PropertyGridItem (Visual Basic)

This sample illustrates how to add constraints to a PropertyGridItem that can be selected through a combo button drop-down list.

Dim Category As PropertyGridItem  
Dim Item As PropertyGridItem  

' Adds a Category to the PropertyGrid titled "Document Settings" category  
Set Category = wndPropertyGrid.AddCategory("Document Settings")  

' Adds a PropertyGridItem to the "Document Settings" category  
Set Item = Category.AddChildItem(PropertyItemString, "Language", "Neutral")  

' Sets the style of the PropertyGridItem, specifies that a combo button will be used  
' to display the constraints, and an edit control is added. The original value  
' of the constraints cannot be edited by the user.  
Item.Flags = ItemHasEdit + ItemHasComboButton  

' Adds several constraint items that can be selected with the combo drop-down list  
Item.Constraints.Add ("Neutral")  
Item.Constraints.Add ("Arabic")  
Item.Constraints.Add ("German")  
Item.Constraints.Add ("Chinese(Taiwan)")  
Item.Constraints.Add ("English")  
Item.Constraints.Add ("France")  
Item.Constraints.Add ("Russian")  

' Illustrates how to retrieve a constraint from the collection  
Debug.Print Item.Constraints(3)  

' Illustrates how to enumerate through each constraint in a PropertyGridItem's collection  
' of constraints.  
Dim Constraint As Variant  
For Each Constraint In Item.Constraints  
    Debug.Print Constraint  
Next

See Also


Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.