TListViewFilterEdit

From Free Pascal wiki
Jump to navigationJump to search

English (en)

ListViewFilterEdit.png

A TListViewFilterEdit is a control, based on TEdit that can manage filtering of the content of a TListView component. It is available from the LazControls tab of the Component Palette.

Usage

Normally you would place a TListViewFilterEdit near its associated TListView and set a number of properties of the two components, typically -

  • ListView1.ViewStyle := vsReport;
  • ListViewFilterEdit1.FilteredListview := ListView1;
  • ListViewFilterEdit1.TextHint := 'Search Here';
  • ListViewFilterEdit1.CharCase := ecNormal;
  • Possibly create one or more columns in the ListView

Adding Data

Data is added via the TListViewFilterEdit and it takes care of passing that data to the TListView. For example, to populate two columns of the TListView you might -

procedure TForm1.AddLVItem(St1, St2 : string);
var
    ListItem: TListViewDataItem;
begin
    ListItem.Data := Nil;
    SetLength(ListItem.StringArray, 2);
    ListItem.StringArray[0] := St1;
    ListItem.StringArray[1] := St2;
    ListViewFilterEdit1.Items.Add(ListItem);
end;

procedure TForm1.LoadSomeData();
begin
    ListView1.BeginUpdate;
    AddLVItem('String1',  'String2');
    AddLVItem('String3',  'String4');
    AddLVItem('A String', 'another String');
    AddLVItem('x string', 'Extra String');
    ListViewFilterEdit1.InvalidateFilter;
    ListViewFilterEdit1.ResetFilter;
    ListViewFilterEdit1.Text:='';
    ListView1.EndUpdate;
end;

Filter Data

By default, TListViewFilterEdit filters only on data in the first column. You can tell it to look at all columns, suppose you have a checkbox called CheckBothColumns -

    ListViewFilterEdit1.ByAllFields := CheckBothColumns.Checked;
    ListViewFilterEdit1.InvalidateFilter;

Case Sensitive

Again, by default, TListViewFilterEdit is not case sensitive but can easily be made so. Again, suppose we have a checkbox, this time called CheckCaseSensitive -

    if  CheckCaseSensitive.checked then
       ListViewFilterEdit1.FilterOptions :=
            ListViewFilterEdit1.FilterOptions + [fsoCaseSensitive]
    else
       ListViewFilterEdit1.FilterOptions :=
            ListViewFilterEdit1.FilterOptions - [fsoCaseSensitive];
    ListViewFilterEdit1.InvalidateFilter;

Other Notes

  • You cannot use TListViewFilterEdit with a TListView in Owner Data Mode.
  • TListViewFilterEdit will only work with data loaded into the TListViewFilterEdit TListView combination, it cannot be made to look at associated data.

The above code can be found in a Lazarus Example that may, at some point in time find its way into the Lazarus Source tree.

See Also


LCL Components
Component Tab Components
Standard TMainMenu • TPopupMenu • TButton • TLabel • TEdit • TMemo • TToggleBox • TCheckBox • TRadioButton • TListBox • TComboBox • TScrollBar • TGroupBox • TRadioGroup • TCheckGroup • TPanel • TFrame • TActionList
Additional TBitBtn • TSpeedButton • TStaticText • TImage • TShape • TBevel • TPaintBox • TNotebook • TLabeledEdit • TSplitter • TTrayIcon • TControlBar • TFlowPanel • TMaskEdit • TCheckListBox • TScrollBox • TApplicationProperties • TStringGrid • TDrawGrid • TPairSplitter • TColorBox • TColorListBox • TValueListEditor
Common Controls TTrackBar • TProgressBar • TTreeView • TListView • TStatusBar • TToolBar • TCoolBar • TUpDown • TPageControl • TTabControl • THeaderControl • TImageList • TPopupNotifier • TDateTimePicker
Dialogs TOpenDialog • TSaveDialog • TSelectDirectoryDialog • TColorDialog • TFontDialog • TFindDialog • TReplaceDialog • TTaskDialog • TOpenPictureDialog • TSavePictureDialog • TCalendarDialog • TCalculatorDialog • TPrinterSetupDialog • TPrintDialog • TPageSetupDialog
Data Controls TDBNavigator • TDBText • TDBEdit • TDBMemo • TDBImage • TDBListBox • TDBLookupListBox • TDBComboBox • TDBLookupComboBox • TDBCheckBox • TDBRadioGroup • TDBCalendar • TDBGroupBox • TDBGrid • TDBDateTimePicker
Data Access TDataSource • TCSVDataSet • TSdfDataSet • TBufDataset • TFixedFormatDataSet • TDbf • TMemDataset
System TTimer • TIdleTimer • TLazComponentQueue • THTMLHelpDatabase • THTMLBrowserHelpViewer • TAsyncProcess • TProcessUTF8 • TProcess • TSimpleIPCClient • TSimpleIPCServer • TXMLConfig • TEventLog • TServiceManager • TCHMHelpDatabase • TLHelpConnector
Misc TColorButton • TSpinEdit • TFloatSpinEdit • TArrow • TCalendar • TEditButton • TFileNameEdit • TDirectoryEdit • TDateEdit • TTimeEdit • TCalcEdit • TFileListBox • TFilterComboBox • TComboBoxEx • TCheckComboBox • TButtonPanel • TShellTreeView • TShellListView • TXMLPropStorage • TINIPropStorage • TJSONPropStorage • TIDEDialogLayoutStorage • TMRUManager • TStrHolder
LazControls TCheckBoxThemed • TDividerBevel • TExtendedNotebook • TListFilterEdit • TListViewFilterEdit • TLvlGraphControl • TShortPathEdit • TSpinEditEx • TFloatSpinEditEx • TTreeFilterEdit • TExtendedTabControl •
RTTI TTIEdit • TTIComboBox • TTIButton • TTICheckBox • TTILabel • TTIGroupBox • TTIRadioGroup • TTICheckGroup • TTICheckListBox • TTIListBox • TTIMemo • TTICalendar • TTIImage • TTIFloatSpinEdit • TTISpinEdit • TTITrackBar • TTIProgressBar • TTIMaskEdit • TTIColorButton • TMultiPropertyLink • TTIPropertyGrid • TTIGrid
SQLdb TSQLQuery • TSQLTransaction • TSQLScript • TSQLConnector • TMSSQLConnection • TSybaseConnection • TPQConnection • TPQTEventMonitor • TOracleConnection • TODBCConnection • TMySQL40Connection • TMySQL41Connection • TMySQL50Connection • TMySQL51Connection • TMySQL55Connection • TMySQL56Connection • TMySQL57Connection • TSQLite3Connection • TIBConnection • TFBAdmin • TFBEventMonitor • TSQLDBLibraryLoader
Pascal Script TPSScript • TPSScriptDebugger • TPSDllPlugin • TPSImport_Classes • TPSImport_DateUtils • TPSImport_ComObj • TPSImport_DB • TPSImport_Forms • TPSImport_Controls • TPSImport_StdCtrls • TPSCustomPlugin
SynEdit TSynEdit • TSynCompletion • TSynAutoComplete • TSynMacroRecorder • TSynExporterHTML • TSynPluginSyncroEdit • TSynPasSyn • TSynFreePascalSyn • TSynCppSyn • TSynJavaSyn • TSynPerlSyn • TSynHTMLSyn • TSynXMLSyn • TSynLFMSyn • TSynDiffSyn • TSynUNIXShellScriptSyn • TSynCssSyn • TSynPHPSyn • TSynTeXSyn • TSynSQLSyn • TSynPythonSyn • TSynVBSyn • TSynAnySyn • TSynMultiSyn • TSynBatSyn • TSynIniSyn • TSynPoSyn
Chart TChart • TListChartSource • TRandomChartSource • TUserDefinedChartSource • TCalculatedChartSource • TDbChartSource • TChartToolset • TChartAxisTransformations • TChartStyles • TChartLegendPanel • TChartNavScrollBar • TChartNavPanel • TIntervalChartSource • TDateTimeIntervalChartSource • TChartListBox • TChartExtentLink • TChartImageList
IPro TIpFileDataProvider • TIpHtmlDataProvider • TIpHttpDataProvider • TIpHtmlPanel
Virtual Controls TVirtualDrawTree • TVirtualStringTree • TVTHeaderPopupMenu