AddChildItemBinded Method
Description
Adds a child item that is bound to the PropertyGridItem. This means that the PropertyGridItem is bound to a variable, and the value of the item is stored in this variable.
Syntax
Public Function AddChildItemBinded( _
ByVal Type As PropertyItemType, _
ByVal Handler As Object, _
ByVal Property As String _
) As PropertyGridItem
Parameters
- Type
Specifies the type of the PropertyGridItem. Possible values include: PropertyItemString: PropertyGridItem of type String.PropertyItemNumber: PropertyGridItem of type Number.PropertyItemBool: PropertyGridItem of type Boolean.PropertyItemColor: PropertyGridItem of type Color.PropertyItemFont: PropertyGridItem of type PropertyGridItemFont.PropertyItemDouble: PropertyGridItem of type Double.PropertyItemDate: PropertyGridItem of type PropertyGridItemDate.PropertyItemPicture: PropertyGridItem of type Picture.PropertyItemEnum: PropertyGridItem of type Enum.PropertyItemEnumFlags: PropertyGridItem of type EnumFlags. This will create a Flags value item in the Property Grid control.PropertyItemCategory: PropertyGridItem is a Category.PropertyItemMultilineString: PropertyGridItem that contains a multi-line string. When using this property, a dropdown button will appear next to the item text that, when clicked, will display an edit window with the entire line of text.-
PropertyItemOption: PropertyGridItem of type PropertyGridItemOption. -
Handler
The object that "handles" the variable the item is binding to, i.e., the object the variable is defined in. -
Property
The name of the variable that will be bound to the PropertyGridItem in string notation.
Remarks
Bound variables store the values of the property grid items and can be accessed without using the property grid methods and properties. Bound variables allow the property grid to store data in variables. Binding works in only one direction. When the value of a PropertyGridItem is changed, the value of the bound variable will be changed to the PropertyGridItem value. If the value of the variable is changed without using the PropertyGrid, the PropertyGridItem value will not change (you would need to explicitly update the PropertyGridItem value with the contents of the variable). The advantage of binding is that the variable can be used and manipulated without using PropertyGridItem methods and properties.
Important Note: When the binding occurs, the variable name is passed to the method in String Notation. String Notation means the name of the variable is placed in quotation marks; within the quotation marks, the variable name can be passed with any combination of spaces and uppercase/lowercase letters, but no extra characters can be added, and they must appear in the same order. For example, when binding to the variable AssembleName, you could pass the variable as "Sassemblename", which is the same as "SASSEMBLE n a m e", but "SAssemble Names" will not work because an extra "s" is added. The reason for this is the variable name passed in String Notation will be used as the PropertyGridItem Caption if no caption is explicitly set.
Note: A variable must be declared within an object's code if it will be bound. This means bound variables cannot be declared in a .bas module.
Example
This sample illustrates how to use the AddChildItemBinded method to bind PropertyGridItems to variables.
Dim Category As PropertyGridItem, ItemAssemble As PropertyGridItem
Dim AssembleName As String
' Variable that the PropertyGridItem will be bound to
AssembleName = "WindowsApplication1"
' Category named "Application" is added to the collection of categories of the first property grid
Set Category = wndPropertyGrid(0).AddCategory("Application")
' Adds a child property item bound to the variable AssembleName. This child is added to
' the "Application" category's collection of childs
Set ItemAssemble = Category.AddChildItemBinded(PropertyItemString, Me, "AssembleName")
' Change the caption of the property item or the default will be used, the default caption
' that will be used is the name of the bound variable
ItemAssemble.Caption = "Name of Application"
See Also
Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.