Class TTreeListView
Unit
TreeListView
Declaration
type TTreeListView = class(TCustomControl)
Description
This is the main TreeListView-class and the only class you need to create yourself.
Simple Example (use in FormCreate), which creates two items one called 'Item' and one called 'Child' where latter shows the value 'Property' in the second column (the tree with the names will be in the first column):
List:=TTreeListView.create(self);
List.Parent:=self;
List.Align:=alClient;
List.Columns.Clear;
List.Columns.Add.Text:='A';
List.Columns.Add.Text:='B';
List.BeginUpdate;
List.Items.Add('Item').SubItems.Add('Child').RecordItemsText[1]:='Property';
List.EndUpdate;
Generally, the treelistview shows its items in a 2d record layout, with the vertical items of a treeview and the horizontal items of a listview.
Former are just called "items", latter are called "record items"; and each record item is associated to a normal item.
Creating normal items
The simplest way to create a new item is by calling the method treelistview.Items.Add('text')
.
This will add a new item with text "text" to the first level of the tree.
If you want to create an item on a deeper level of the tree i.e. as sub item to a given parent item, you can call either treelistview.Items.Add(parent, 'text')
or parent.subitems.add('text');
If you're going to add several items, you should call treelistview.BeginUpdate
and treelistview.EndUpdate
.
Creating record items
To add a record item to a given item
e.g. to set its text in column i
, you can just call item.RecordItemsText[i]:='text';
Hierarchy
- TCustomControl
- TTreeListView
Overview
Fields
Methods
Properties
Description
Fields
Methods
|
procedure UpdateScrollSizeH; |
Warning: this symbol is deprecated.
Recalculates the necessary scrollbar properties Normally you don't need to call this
|
|
procedure UpdateScrollSizeV; |
Warning: this symbol is deprecated.
Recalculates the necessary scrollbar properties Normally you don't need to call this
|
|
procedure UpdateScrollSize; |
Warning: this symbol is deprecated.
Recalculates the necessary scrollbar properties Normally you don't need to call this
|
|
constructor Create(aowner:TComponent); override; |
Create
|
|
procedure loaded; override; |
|
|
function GetItemAtPos(const y:integer):TTreeListItem; |
Returns the item at position y
|
|
function GetRecordItemAtPos(const x,y:integer):TTreeListRecordItem; |
Returns the record item at position x,y Notice that it doesn't check for visibility, e.g you can use negative coordinates or find items hidden by the scrollbars
|
|
procedure BeginUpdate; |
Notifies the control that the items are changed, so it will not redrawn itself. Never forget to use this, otherwise it will be very slow.
|
|
procedure EndUpdate; |
Stops the redraw block and redraws everything
|
|
function VisibleRowCount:longint; |
Count of visible lines
|
|
procedure sort; |
Sorts the items according to the current sorting options
|
|
procedure ensureVisibility(item: TTreeListItem;column: longint=-1); |
Makes item visible, this includes scrolling and expanding of items If column is not -1 it scroll horizontally to the beginning/ending of this column if it isn't visible
|
|
function search(searchFor: string; searchFields:cardinal; backward: boolean=false;extendSelection: boolean=false): TFindState; overload; |
This searches the text searchFor in searchFields and marks it.
Parameters
- searchFields
- Bit-wise combination of column numbers. Use
1 shl i for column i. (you can only use the first 32 columns)
- backward
- Specifies
search direction
- extendSelection
- set this to true for an incremental
search
|
|
function ColumnFromOriginalIndex(index: longint): THeaderSection; |
If the columns can be dragged this will return them in the old order
|
|
procedure ColumnsAutoSize; |
|
|
procedure CreateUserColumnVisibilityPopupMenu(); |
Creates a popupmenu to hide/show columns You need to call this method after every removing/creating of columns, because the TreeListView doesn't known when the columns are changed, since you have direct access to the headercontrol sections. This needs FPC
|
|
function serializeColumnOrder: string; |
save the order of the columns in a string (needs FPC)
See also
- deserializeColumnOrder
- load the order of the columns from a string (needs FPC)
|
|
procedure deserializeColumnOrder(s: string); |
load the order of the columns from a string (needs FPC)
See also
- serializeColumnOrder
- save the order of the columns in a string (needs FPC)
|
|
procedure deserializeColumnVisibility(s: string); |
load the visibility of the columns from a string (needs FPC)
See also
- serializeColumnVisibility
- save the visibility of the columns in a string (needs FPC)
|
|
procedure CreateSearchBar(); |
Creates a FireFox like SearchBar
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override; |
|
|
procedure WndProc(var message:TMessage); override; |
|
|
procedure sheduleInternRepaint(); |
This method will soon repaint all items. This means as soon as the calling functions finished (= returns to the application message loop) and all pending messages are processed, internRepaint will be called
See also
- internPaint
- This method will paint all changed items on the screen.
- sheduleInternRepaint
- This method will soon repaint all items.
- invalidateAll
- This invalidates all items, so the whole control will be redrawn if next painting occurs
- invalidateItem
- This invalidates the passed item, so that it will be redrawn if the next painting occurs
|
|
procedure internPaint(calledFromPaintingEvent: boolean=false); |
This method will paint all changed items on the screen. This means it will call internDraw to draw all changed item in the double buffer and then copy the changed areas of the double buffer on the screen
See also
- sheduleInternRepaint
- This method will soon repaint all items.
- internRepaint
- This method forces a redraw of all items (=invalidateAll and internPaint)
- invalidateAll
- This invalidates all items, so the whole control will be redrawn if next painting occurs
- invalidateItem
- This invalidates the passed item, so that it will be redrawn if the next painting occurs
|
|
procedure Paint; override; |
This is the normal Delphi/Lazarus painting routine called when a paint message is received. You should call it seldom.
See also
- sheduleInternRepaint
- This method will soon repaint all items.
- internRepaint
- This method forces a redraw of all items (=invalidateAll and internPaint)
- invalidateAll
- This invalidates all items, so the whole control will be redrawn if next painting occurs
- invalidateItem
- This invalidates the passed item, so that it will be redrawn if the next painting occurs
|
|
destructor Destroy; override; |
|
Properties
|
property selCount: longint read F_SelCount; |
Count of selected items
|
|
property focused: TTreeListItem read F_Focused write SetFocused; |
Currently focused item, it is not necessarily selected. Setting this property will not select the new item
|
|
property Selected: TTreeListItem read F_Focused write SetSelected; |
This is the same as Focused, but setting this property will select the item and deselect every other one
|
|
property SortColumn: longint read F_SortColumn write SetSortColumn; |
Column currently used for sorting
|
|
property TopPos: integer read GetTopPos; |
V-Scrollposition calculated in pixels (=position of Items[0])
|
|
property TopItem: TTreeListItem read GetTopItem write SetTopItem; |
Visible item with the least real index (can be nil)
|
|
property TopItemIsEvenItem: boolean read GetTopItemEven; |
Is the top item even (used for striping)
|
|
property TopItemVisualIndex: integer read GetTopItemVisualIndex; |
Index of the top item, if all visible items were in a single list
|
|
property DrawingEvenItem: boolean read F_DrawingEvenItem; |
Is the currently drawn item even (only valid during custom draw events, having this as property prevents parameter cluttering)
|
|
property DrawingYPos: longint read F_DrawingYPos; |
Y-Position of the currently drawn item (only valid during custom draw events, having this as property prevents parameter cluttering)
|
|
property DrawingRecordItemRect: TRect read F_DrawingRecordItemRect; |
boundaries of the currently drawn record item (only valid during custom draw events, having this as property prevents parameter cluttering)
|
|
property Columns: THeaderSections read GetColumns write SetColumns; |
All columns
|
|
property RowHeight: integer read F_RowHeight write SetRowHeight; |
Height of a row
|
|
property Images: TImageList read F_ImageList write setImageList; |
ImageList used to get the images for items using the TTreeListView.ImageIndex property
|
|
property HorizontalLineMode: TLineMode read F_HorizontalLines write SetHorizontalLines; |
Determines how/if lines are drawn between the items
|
|
property HorizontalLineColor: TColor read F_HorizontalLineColor write SetHorizontalLineColor; |
|
|
property VerticalLineMode: TLineMode read F_VerticalLines write SetVerticalLines; |
Determines how/if lines are drawn between the columns
|
|
property VerticalLineColor: TColor read F_VerticalLineColor write SetVerticalLineColor; |
|
|
property RootLineMode: TLineMode read F_RootLines write SetRootLines; |
Determines how/if lines are drawn to connect the tree items
|
|
property RootLineColor: TColor read F_RootLineColor write SetRootLineColor; |
|
|
property ColorSearchMark: tcolor read F_ColorSearchMark write SetColorSearchMark; |
|
|
property ColorSearchMarkField: tcolor read F_ColorSearchMarkField write SetColorSearchMarkField; |
|
|
property ExpandMode: TExpandMode read F_ExpandMode write SetExpandMode; |
Determines how/if the user is allowed to collapse/expand items
|
|
property HotTrackFont: TFont read F_HotTrackFont write SetHotTrackFont; |
|
|
property Font; |
|
|
property SelectedFont: TFont read F_SelectedFont write SetSelectedFont; |
|
|
property SelectedHotTrackFont: TFont read F_SelectedHotTrackFont write SetSelectedHotTrackFont; |
|
|
property StripedOddColor: TColor read F_StripedOddColor write SetStripedOddColor; |
|
|
property StripedEvenColor: TColor read F_StripedEvenColor write SetStripedEvenColor; |
|
|
property SelectBackColor: TColor read F_SelectBackColor write SetSelectBackColor; |
|
|
property ButtonColor: TColor read F_ButtonColor write SetButtonColor; |
Color of the expand/collaps button
|
|
property BackGroundColor: TColor read F_BgColor write SetBgColor; |
|
|
property Items: TTreeListItems read F_Items write SetItems; |
All the items , use items.add to create new ones
|
|
property Scrollbars: TScrollStyle read F_ScrollStyle write SetScrollStyle; |
|
|
property HeaderVisible: boolean read F_HeaderVisible write SetHeaderVisible; |
|
|
property OnCompareItems: TCompareTreeListItemsEvent read F_OnCompareItems write F_OnCompareItems; |
Event which is called when two items are compared during sorting The default sorting is case-insensitive lexicographical on text and numerical on number string parts, every level is sorted on its own, parents are not changed
|
|
property OnUserSortItemsEvent: TUserSortItemsEvent read F_OnUserSortItems write F_OnUserSortItems; |
Called when the user clicks on the header to resort the items
|
|
property OnItemsSortedEvent: TNotifyEvent read F_OnItemsSorted write F_OnItemsSorted; |
Called after the items have been sorted
|
|
property OnVScrollBarChange: TNotifyEvent read F_VScrollBarChange write F_VScrollBarChange; |
|
|
property OnHScrollBarChange: TNotifyEvent read F_HScrollBarChange write F_HScrollBarChange; |
|
|
property OnCustomItemDraw: TCustomItemDrawEvent read F_CustomItemDraw write F_CustomItemDraw; |
This is called before/after an item is drawn
See also
- TTreeListItem.PaintTo,
|
|
property OnCustomRecordItemDraw: TCustomRecordItemDrawEvent read F_CustomRecordItemDraw write F_CustomRecordItemDraw; |
This is called before/after any record items is drawn
|
|
property OnCustomRecordItemPositioning: TCustomRecordItemPositioningEvent read F_CustomRecordItemPositioningEvent write F_CustomRecordItemPositioningEvent; |
This is called when the position of a record item is calculated
|
|
property OnClickAtRecordItem: TRecordItemEvent read F_ClickAtRecordItem write F_ClickAtRecordItem; |
Called when the user clicks on a record item
|
|
property OnClickAtItem: TItemEvent read F_ClickAtItem write F_ClickAtItem; |
Called when the user clicks on an item (if you need the column use OnClickAtRecordItem)
|
|
property OnSelect: TItemEvent read F_OnSelect write F_OnSelect; |
Called when an item is selected or deselected
|
|
property OnItemCollapsed: TItemEvent read F_OnItemCollapsed write F_OnItemCollapsed; |
Called when an item is collapsed
|
|
property OnItemExpanded: TItemEvent read F_OnItemExpanded write F_OnItemExpanded; |
Called when an item is expanded
|
|
property OnHeaderSectionResize: TCustomSectionNotifyEvent read F_HeaderSectionResize write F_HeaderSectionResize; |
|
|
property OnHeaderSectionTrack: TCustomSectionTrackEvent read F_HeaderSectionTrack write F_HeaderSectionTrack; |
|
|
property TabStop default true; |
|
|
property TabOrder; |
|
|
property Align; |
|
|
property Anchors; |
|
|
property Constraints; |
|
|
property DragCursor; |
|
|
property DragKind ; |
|
|
property DragMode ; |
|
|
property Hint ; |
You can't use this if tooltips is true
|
|
property PopupMenu; |
|
|
property ShowHint ; |
|
|
property OnDockDrop; |
|
|
property OnDockOver; |
|
|
property OnEnter; |
|
|
property OnExit; |
|
|
property OnGetSiteInfo; |
|
|
property OnKeyDown; |
|
|
property OnKeyPress; |
|
|
property OnKeyUp; |
|
|
property OnMouseWheel; |
|
|
property OnMouseWheelDown; |
|
|
property OnMouseWheelUp; |
|
|
property OnUnDock; |
|
|
property OnClick; |
|
|
property OnConstrainedResize; |
|
|
property OnDblClick; |
|
|
property OnDragDrop; |
|
|
property OnDragOver; |
|
|
property OnEndDock; |
|
|
property OnEndDrag; |
|
|
property OnMouseDown; |
|
|
property OnMouseMove; |
|
|
property OnMouseUp; |
|
|
property OnResize; |
|
|
property OnStartDock; |
|
|
property OnStartDrag; |
|
Generated by PasDoc 0.16.0.