[Overview][Types][Classes][Procedures and functions][Index] | Reference for unit 'ShellCtrls' (#lcl)

# TCustomShellListView.PopulateWithRoot

Fills the list view with file system information for the directory in Root.

## Declaration

Source position: shellctrls.pas line 282

`protected procedure TCustomShellListView.PopulateWithRoot;`

## Description

PopulateWithRoot is a procedure used to fill the Items property with file system entries for the directory specified in Root.

No actions are performed in the method at design-time, or when Root contains an empty string (''). In addition, the actions may be delayed if the Handle for control has not been allocated. An internal flag is set to indicate the condition, and PopulateWithRoot will be called again when the Handle is created in CreateHandle.

PopulateWithRoot calls the GetFilesInDirectory helper routine in the implementation section to get a list of file system items for the path which match the Mask and ObjectTypes specified for the control. Each of the files in the list are passed to DoAddItem / OnAddItem to determine if they can be added to the Items property.

The add method in Items is called to create the list items which represent each of the files or directories. If a list item is a TShellListItem class type, its FileInfo property is updated with the file information from the TFileItem created in the GetFilesInDirectory helper.

The Caption is used to store the file or directory name in the list item. The Data property in the list item is used to store a pointer to the file size. Values are added to SubItems in the list item to store the string representation for the file size, and the file extension.

When UseBuiltInIcons is set to True, the GetBuiltInImageIndex method is called to get the ImageIndex for the built-in icon on a list item. This action is performed using the path to the current file name when LargeImages and/or SmallImages have not been assigned. The value in ViewStyle determines the image size requested. When ViewStyle is vsIcon, LargeImages is checked (when assigned). Otherwise, SmallImages is checked (when assigned). If an image list exists in either LargeImages or SmallImages, the existing ImageIndex in the list item is used.

The OnFileAdded event handler is signalled (when assigned) for each new entry added to Items.

The Sort method is called prior to exit to order the Items in the control using the option specified in the FileSortType property.

## Version info

Updated in LCL version 3.0 to use TShellListItem as the item class for list items.

## See also

TCustomShellListView.Root |  | Indicates the initial directory path whose objects are displayed in the control.
TCustomShellListView.Items |  | Collection of list items displayed on the list view control.
TCustomShellListView.Mask |  | File mask used to select items displayed in the shell control.
TCustomShellListView.ObjectTypes |  | Controls which file system objects are visible on the list view control.
TCustomShellListView.UseBuiltInIcons |  | Indicates if icons provided by the OS or platform are used for items in the list.
TCustomShellTreeView.FileSortType |  | Indicates the sort type used for items (tree nodes) on the tree view control.
TCustomShellListView.DoAddItem |  | Signals the OnAddItem event handler when an entry is added to the Items in the control.
TCustomShellListView.OnAddItem |  | Event handler signalled to determine if the specified file information can be added to the Items for the list view.
TCustomShellListView.OnFileAdded |  | Event handler signalled when a file is added to the Items in the control.
TCustomShellListView.CreateHandle |  | Creates the handle for the control and populates the Items property.
TShellListItem |  | Implements the class used for list items maintained in TShelllListView.
TAddItemEvent |  | Specifies an event handler signalled when an item is added to a shell control.
TCSLVFileAddedEvent |  | Specifies an event handler signalled when an item is added to TCustomShellListView.