PropertyGridItemConstraint Object
Description
The PropertyGridItemConstraint Object represents a single item constraint.
For a list of all members defined in this module, see PropertyGridItemConstraint Members.
Remarks
Each PropertyGridItem has its own collection of constraints. The constraints collection allows access to the constraints of a given item. If a combo button is added to the property grid item, all the constraints in the item's constraint collection will be displayed in the drop-down list. The Add method is used to add constraints to the collection.
The Data property of the PropertyGridItemConstraint can be used to associate a value of type Long to a PropertyGridItem of any type.
Items of type PropertyItemEnum and PropertyItemEnumFlags require a list of constraints and use the Data property to determine the value and text of the item.
Example
EnumFlags (Constraints with Data) Sample (Visual Basic)
This sample illustrates how to use an item of type PropertyItemEnumFlags. The EnumFlags item uses PropertyGridItemConstraints that have both Caption and Data.
Dim ItemFlags As PropertyGridItem
' Adds an item of type EnumFlags with a default value of 1 + 8 = 9 = [Windows 98; Windows 95]
Set ItemFlags = Category.AddChildItem(PropertyItemEnumFlags, "Flags", 1 + 8)
' Adds a constraint that will set all items TRUE or FALSE, note the value of the constraint is the sum
' of all the other constraints. This item will also be updated when the values of the other constraints
' have changed.
ItemFlags.Constraints.Add "All Windows", 1 + 2 + 4 + 8 + 16 + 32
' Adds some constraints that can have a value of TRUE or FALSE
ItemFlags.Constraints.Add "Windows 98", 1
ItemFlags.Constraints.Add "Windows 2000", 2
ItemFlags.Constraints.Add "Windows XP", 4
ItemFlags.Constraints.Add "Windows 95", 8
ItemFlags.Constraints.Add "Windows NT", 16
ItemFlags.Constraints.Add "Windows 2003", 32
' This changes the value of the flag item to 21 and the string
' caption to [Windows 98; Windows XP; Windows NT]
ItemFlags.Value = 21
' Returns the sum of all true constraints
Debug.Print "Flags Item Value = " & ItemFlags.Value
' Returns a string containing the text of all true constraints
Debug.Print "Flags Item String = " & ItemFlags.MaskedText
See Also
Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.