Implements an edit control used to filter an associated TListView control.

listviewfilteredit.pas contains classes and types used to implement the TListViewFilterEdit control. It is used to filter the items displayed for an associated TListView control by the caption or sub-items in list item data.

listviewfilteredit.pas is part of the LazControls package.

Record type with data and lines of text for an item in a list view control.

TListViewDataItem is the typed maintained in TListViewDataList, and passed an argument to the method in TListViewFilterEdit which finds matches for its Filter criteria.

Pointer to the data for the list item.
TListItem.Data
Array of String values with the text displayed for the list item.
TStringArray
Implements the Equal (=) comparison operator for TListViewDataItem instances.

The return value is True when both the Data and the StringArray for the compared TListViewDataItem instances are the same.

True when the compared items have the same Data and StringArray values.
TListViewDataItem instance for the comparison operator.
TListViewDataItem instance for the comparison operator.
List container for TListViewDataItem instances.

TListViewDataList is a specialization of TFPGList to use TListViewDataItem instances in the container. TListViewDataList is the type used to implement the Items property in TListViewFilterEdit.

Implements a control used to filter list items in an associated TListView control.

TListViewFilterEdit is a TCustomControlFilterEdit descendant which implements a control used to filter list item data from an associated TCustomListView control. It includes the FilteredListview property which provides the original list items and selections, and displays the filtered results. Overridden methods are provided to apply the filter and sort the list items for the associated list view control. The button on the edit control is used to clear the filter applied to the list items. Other overridden methods are provided to navigate between and select the filtered list items.

TListViewFilterEdit requires FilteredListview to have list items available in its Items property. This prevents use of virtual mode (when OwnerData is True) in the associated list view control.
TCustomControlFilterEdit
TListView control showing the filtered data.
Stores the value for the ByAllFields property.
Stores / restores the previous selections in the associated control.
Data supplied by the caller through the Items property.
Data sorted for viewing.
True when the list view item matches a filter condition for the control.
True when the list view item matches a filter condition for the control.
TListViewDataItem instance with the strings and a pointer to data used in the filter comparison.
Sets the value for the ByAllFields property.
New value for the ByAllFields property.
Sets the value for the FilteredListview property.
New value for the FilteredListview property.
Handles a notification message received when a component is added to or removed from the control.

Overridden in TListViewFilterEdit to ensure that the FilteredListview property is set to Nil when the component is removed from the control.

TControl.Notification
Component for the notification message.
Operation for the component.
Gets the ordinal position for the last selected list view item.

The return value is retrieved from the Index property in LastSelected (when assigned). The value is -1 if LastSelected has not been assigned.

TCustomListView.LastSelected
Ordinal position for the last selected list view item, or -1 when LastSelected has not been assigned.
Changes the selection for the associated list view control to the specified item position.
Ordinal position for the list item to select, multi-select, or de-select.
True if the item is selected or included in a multi-selection.
Moves the list view control to the next list item.

MoveNext is an overridden method in TListViewFilterEdit used to position the associated list view control on the next list item which matches the filter condition. The value in LastSelected is used as the starting point for the navigation request.

MoveNext calls the MoveTo method to reposition the list view and determine the existing selected state for the list item.

ASelect indicates whether the list item is included in the Selection (multi-selection) for the list view control.

No actions are performed in the method when FilteredListview has not been assigned, or does not contain any list items.

TCustomControlFilterEdit.MoveNext
True if the new list item should become selected, or added to the multi-selection for the list view control.
Moves the associated list view control to the previous list item.
True if the list item should be become selected (or multi-selected).
Moves the associated list view control towards the start of its list items by the number of visible rows for the control.
True if the list item should be become selected (or multi-selected).
Moves the associated list view control towards the end of its list items by the number of visible rows for the control.
True if the list item should be become selected (or multi-selected).
Move the associated list view control to the first list item.
True if the list item should be become selected (or multi-selected).
Move the associated list view control to the last list item.
True if the list item should be become selected (or multi-selected).
Returns True if a Return or Enter key press was forwarded to the list view control.

ReturnKeyHandled is an overridden Boolean function used to the signal the OnKeyPress event handler in FilteredListView when a Return (Enter) key down event is handled for the edit box on the control. No actions are performed in the method if either FilteredListView or its OnKeyPress event handler have not been assigned.

TCustomControlFilterEdit.ReturnKeyHandled TCustomControlFilterEdit.EditKeyDown TWinControl.OnKeyPress
True if a Return (Enter) key press was forwarded to the list view control.
Sorts the data in the associated control and applies the filter.

SortAndFilter is an overridden method in TListViewFilterEdit which implements the abstract virtual method from the ancestor class. It discards previous filtering results and re-evaluates the filter condition(s) for each of the list items in FilteredListview.

TCustomControlFilterEdit.SortAndFilter TCustomControlFilterEdit.DoFilterItem TCustomControlFilterEdit.OnFilterItem TCustomControlFilterEdit.OnFilterItemEx
Implements the method used to apply filter data to the associated control.

Called when the ApplyFilter method in the ancestor class is executed.

Gets the default resource name for the button glyph on the control.
Resource name for the button glyph.
Constructor for the class instance.

Create is the overridden constructor for the class instance, and calls the inherited method on entry. It allocates resources for the SelectionList and Items properties. It creates an internal TListViewDataList instance used to store the filtered data for the list view control.

Owner of the class instance.
Destructor for the class instance.

Destroy is the overridden destructor for the class instance. It frees resources allocated to SelectionList, Items, and the internal filtered data list. It calls the inherited method prior to exit.

Clears the selection list for the control, and stores any list items from FilteredListview with their Selected property set to True.

StoreSelection is an overridden method in TListViewFilterEdit. It implements the abstract virtual method from the ancestor class. StoreSelection calls the Clear method in SelectionList to remove existing values in the list. When FilteredListview has selected items (SelCount > 0), the Caption for each selected TListItem is added to SelectionList.

No actions are performed in the method if FilteredListview has not been assigned.

StoreSelection is used in the implementation for the ApplyFilter method in the ancestor class.

See RestoreSelection for the action performed to select the list items in SelectionList in the Items for the associated TListView control.

TCustomControlFilterEdit.StoreSelection TCustomListView.Items TListItems TListItem.Selected
Restores the Selected property for list items in FilteredListview which are stored in StoreSelection.

RestoreSelection is an overridden method in TListViewFilterEdit. It implements the abstract virtual method from the ancestor class.

RestoreSelection locates and updates the Selected property for TListItem entries found in th associated TListView control. RestoreSelection visits each of the caption values in SelectionList and calls the IndexOf method for the Items in FilteredListview. When a caption value is located, the Selected property for the TListItem entry is set to True.

No actions are performed in the method when SelectionList does not contain any caption values (Count = 0) or when FilteredListview has not been assigned.

RestoreSelection is used in the implementation for the ApplyFilter method in the ancestor class.

See StoreSelection for the actions performed to store the selected items in FilteredListview to the SelectionList property.

TCustomControlFilterEdit.RestoreSelection TCustomListView.Items TListItems TListItem.Selected
Identifies the selected items in the associated TListView control.

SelectionList is a read-only TStringList property which contains the list items which are marked as selected in FilteredListview. It contains the caption for the TListItem entries in FilteredListview which have their Selected property set to True.

Caption values are stored in the property when StoreSelection is called when the Filter value is applied to the associated list view control. SelectionList is cleared and reloaded each time StoreSelection is called.

RestoreSelection is used to re-apply the selected state for list items in FilteredListview when the Filter is cleared for the control.

TCustomControlFilterEdit.Filter TCustomListView.Items TCustomListView.SelCount TListItems TListItem.Caption TListItem.Selected
Maintains the data which is filtered and shown in the ListView.
The associated list view for the filtered edit control.

FilteredListview is a TCustomListView property with the list view control which contains the list item data and selections filtered in the control.

Applications must assign a value to the property to enable filtering in edit control. No actions are performed in the control when FilteredListview has not been assigned (contains Nil), or FilteredListView does not contain any list items in its Items property.

Changing the value in the property causes the filter Text to be re-applied to the control by calling the InternalSetFilter method. Values in the Items property are updated to reflect the list Items in FilteredListView after the filter has been applied.

Use the ByAllFields property to control whether SubItems in the list item data are included in the filtered values for the control.

TCustomControlFilterEdit.Filter TCustomControlFilterEdit.InternalSetFilter TCustomControlFilterEdit.Text TCustomListView
Indicates whether all fields are compared using the filter.

ByAllFields is a Boolean property which controls the properties used to find matches for the Filter in the control. When set to True, all properties in a TListViewDataItem are used when searching for a value that matches the Filter. Otherwise, only the Caption (element 0 in the list item data) is used.

The default value for the property is False. Changing the value for the property causes the inherited InvalidateFilter method to be called to update the control.

ByAllFields is used in the MatchesFilter method called when list item data is selected and sorted for the control.