Selecting Property Tabs in Microsoft PropertyGrid
The PropertyGrid control supports multiple property views: alphabetical, categorized, etc. To switch between different views, the user can select the corresponding button on the grids embedded toolbar. It is also possible to switch between the property tabs programmatically by using the grids internal
Below I will explain how you can implement both approaches in TestComplete scripts.
Simulating Toolbar Button Clicks
The PropertyGrid control has an embedded toolbar that can be used to switch between the property views. The toolbar is visible if the grids
ToolbarVisible property is True. If so, you can obtain the object corresponding to the toolbar control and then select the needed property tab by simulating a click on the corresponding toolbar button.
The object that corresponds to the grid toolbar appears as the grids child object, and you can address it using the
WinFormsObject method. The notation used to address the toolbar depends on the PropertyGrid control version used in the application:
- for applications created in Microsoft Visual Studio .NET:
- for applications created in Microsoft Visual Studio 2005:
To simulate a click on PropertyGrids toolbar item, you can use the
ClickItem action added to toolbar objects by TestComplete. The item to be clicked can be specified by its position within the toolbar, starting from 0: the position of the Categorized button is 0, the Alphabetical button - 1, and so on. For Visual Studio 2005 applications, it is also possible to specify the toolbar item by its caption Categorized, Alphabetical, and so on.
Below is an example that demonstrates how you can switch between PropertyGrid tabs by clicking toolbar buttons:
Using the PropertyGrid.PropertySort Property
The PropertyGrid control has the
PropertySort property that can be used to determine or specify the sort type in the grid. You can set this property to one of the following values: NoSort (0), Alphabetical (or 1), Categorized (or 2) or CategorizedAlphabetical (or 3; in fact, it is the same as Categorized). This will make the corresponding property tab selected in the grid.
The following code snippet demonstrates how you can use the
PropertySort property to change the grids active tab: