PropertyGridUpdateContext Object
Description
The PropertyGridUpdateContext object is used to save the current state of the property grid, such as the currently selected item, PropertySort preference, and the expanding state of each item in the grid.
For a list of all members defined in this module, see PropertyGridUpdateContext members.
Remarks
The property grid state information is stored in the PropertyGridUpdateContext object when BeginUpdate is called, and after EndUpdate, the expanding state of each item, selected item, and sort preference will be restored.
Each time you add a new item or category to the grid, the state of the grid is updated and the grid is redrawn. If you want to delete all items in the grid and then add a lot of new items, it will be quite slow. To do this, you would call BeginUpdate, then delete all the items. The property grid will be locked until you call EndUpdate.
Note: The PropertyGridUpdateContext object is used internally by the Property Grid and has no programmable methods or properties.
Example
PropertyGridUpdateContext Sample (Visual Basic)
This sample illustrates how to use the PropertyGridUpdateContext object to update large amounts of data in the property grid.
' The UpdateGrid subroutine will clear the current contents of the grid and add
' a large amount of items.
Private Sub UpdateGrid()
' This is the UpdateContext that the grid will use for the update.
Dim gridUpdate As PropertyGridUpdateContext
' Begin the update process. This will lock the Property Grid and the user
' will not be able to interact with the grid during the update.
Set gridUpdate = wndPropertyGrid.BeginUpdate
' Removes all items and categories from the grid.
wndPropertyGrid.Categories.Clear
Dim Category As PropertyGridItem, Item As PropertyGridItem
Dim iCategory As Integer, iItem As Integer
' This is a stress test loop that will illustrate how much the BeginUpdate and EndUpdate methods can impact a large update.
' There will be 500 categories, each category will have 100 child items and each category will be expanded.
' When using the BeginUpdate and EndUpdate methods, this loop should take around 15-30 seconds.
' Without the BeginUpdate and EndUpdate methods, this loop should take around 4-5 minutes!
For iCategory = 0 To 200
Set Category = wndPropertyGrid.AddCategory("Category " & iCategory)
For iItem = 0 To 100
Set Item = Category.AddChildItem(PropertyItemBool, "Item " & iItem, True)
Next
Category.Expanded = True
Next
' Ends the update process. All of the changes made to the grid will now be visible.
' And the user can now interact with the grid again.
wndPropertyGrid.EndUpdate gridUpdate
End Sub
See Also
Copyright (c) 1998-2024 Codejock Technologies. All rights reserved.