Skip to content

Id Property

Description

The Id property is used to get or set an Id for the item.

Property Type

Read-write property

Syntax (Visual Basic)

Public Property Id() As Long

Remarks

The Id can be used to uniquely identify the property grid item. The FindItem method can be used to search for an item by Id.

To associate any extra data needed for your program with the item, the Tag property can be used.

Example

Assigning an Id to Property Grid Items (Visual Basic)

This sample illustrates how to assign an Id to a property grid item.

'Ids of items  
Const ID_STRING_ITEM = 200  
Const ID_NUMBER_ITEM = 201  

Dim Category As PropertyGridItem  
Dim Item As PropertyGridItem  

' Adds a category named "Items" to the property grid  
Set Category = wndPropertyGrid.AddCategory("Items")  

' Adds an item to the "Items" category  
Set Item = Category.AddChildItem(PropertyItemString, "StringItem", "String")  
' Assigns an Id to the Item  
Item.Id = ID_STRING_ITEM  

' Adds an item to the "Items" category  
Set Item = Category.AddChildItem(PropertyItemNumber, "NumberItem", 10)  
' Assigns an Id to the Item  
Item.Id = ID_NUMBER_ITEM  

' Searches the collection of items for the item with Id ID_STRING_ITEM and returns the item  
Set Item = wndPropertyGrid.FindItem(ID_STRING_ITEM)  
If Not Item Is Nothing Then  
    ' If found, replace the value of the item with "Sample Text"  
    Item.Value = "Sample Text"  
End If  

See Also


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