Skip to main content

ListView and TreeView Controls

Controls derived from SysTreeView32 and SysListView32 are supported using the following methods.

ListView

MethodDescription
GetListItemCountReturn the number of items in the List
GetListItemLocationReturn the location coordinates of the item with the given index number
GetListItemTextReturn the test of the item for the given index and column
GetListItemPointFromNameReturn the location of the item with the given name and column
EnsureVisibleListItemScroll the list view to ensure the item given by an index number is visible
SelectListItemSet the item given by the index number to the selected state

TreeView

MethodDescription
GetTreeViewItemCountReturn the number of visible items in the Tree
GetTreeItemLocationReturn the location coordinates of the item with the given name
GetTreeItemRectangeReturn the rectangle enclosing the item
ExpandTreeItemReturn the location of the item
EnsureVisibleTreeItemScroll the list view to ensure the item is visible
SelectTreeItemSet the item to the selected state
GetTreeItemTextGet the text of the item for the given index number

Example

This example shows a method for finding desktop Icon and double clicking it. The Windows desktop is a SysListView32 control.

public void LaunchDesktopItem(string name)
{
Control desktop = FindTopWindow("Program Manager");
Control listview = desktop.FindControl("FolderView");
for (int i = 0; i < listview.GetListItemCount(); i++)
{
if (listview.GetListItemText(i, 0).Equals(name))
{
Mouse.DoubleLeftClick(listview.GetListItemLocation(i));
return;
}
}
ExitVU("Failed to find desktop item: " + name, false);
}