Description


It serves for output and creation of data in a hierarchical form (tree structure). An example of hierarchical data is the structure of a company.



Class: TdbTreeView



Properties

 Property

 Type

 Description

 dbFilter

 String

 Allows you to set an additional filter that will be used to populate the component with data from the database. For example: tablename.fieldname = 1

 dbForeignKey

 String

 Specifies which foreign key of the database table this component belongs to. If necessary, you can specify the name of the table.

 dbFieldParentID

 String

 Specifies the field that will be used to form the tree structure. The field must be of type "Integer".

 dbGetSqlStatement

 String

 The property allows you to get the last SQL query that was used to populate the component with data from the database.

 dbIncremSearch

 String

 Allows you to specify the name of the button on the current form with the "Search" or "SQL query" action, which will be automatically pressed when user changes the value of the component. The property is necessary to implement instant search.

 dbItemID

 Integer

 The identifier of the selected record in the component. The identifier corresponds to the id field in the database.

 dbListFieldsNames

 String

 Contains header names for columns separated by commas.

 dbPopupMenu

 TPopupMenu

 Provides access to the component's popup menu. More info.

 sqlValue

 String

 Returns the id of the selected record in the component for use in SQL queries. In case of empty value, it returns NULL string

 example: SQLExecute ('INSERT INTO tablename (fieldname) VALUES ('+Form1.TreeView1.sqlValue+')');

 BorderStyle

 TBorderStyle

 Определяет наличие бордюра у компонента. Доступные значения: bsSingle, bsNone

 CanFocus

 Boolean

  It checks if the component can get input focus, which is usually necessary before using the SetFocus method. If a component has Visible = False or Enabled = False property, or if the component is located on a parent component with those properties, using the SetFocus method will cause an error.


example: if Form1.TreeView1.CanFocus then Form1.TreeView1.SetFocus;

 Canvas

 TCanvas

 A class that allows you to draw on a component. More info.

 Cell[x,y]

 TCell

 Property to access additional properties of the specified component cell (x - column, y - row). More info.

 Cells[x,y]

 String

 Property for accessing the text content of a cell (x - column, y - row).

 ClientWidth

 Integer

 The width of the client part of the component (i.e. excluding borders).

 ClientHeight

 Integer

 The height of the client part of the component (i.e., excluding the borders).

 Color

 TColor

 The background color of the component. More info.

 Columns

 TNxColumns

 Property to access additional column properties and methods. More info.

 Columns[i]

 TNxCustomColumn

 Property to access the properties of a specified column. More info.

 Cursor

 TCursor

 Specifies the image used to represent the mouse pointer when it passes into the region covered by the control. More info.

 Enabled

 Boolean

 Controls whether the component responds to mouse, keyboard, and timer events.

 Expanded [Index: Integer]

 Boolean

 Defines the state of the node (expanded or collapsed).

 FixedCols

 Integer

 Sets the number of fixed columns that will not move when scrolling horizontally.

 Focused

 Boolean

 Determines whether the control has input focus.

 Font

 TFont

 Allows you to set font name, size, color and style. More info.

 HeaderSize

 Integer

 Gets or sets size of columns headers.

 Hint

 String

 Hint contains the text string that appears when the user moves the mouse over the component., see also ShowHint

 HorzScrollBar

 TNxScrollBar

 Property to access additional scrollbar properties and methods. More info.

 LastAddedRow

 Integer

 Returns the index of the last added line. Read-only.

 Name

 String

 The name of the component.

 Options

 TGridOptions

 Additional component settings. More info.

 Parent

 TWinControl

 The parent component on which this component is placed.

 RowCount

 Integer

 Gets total number of rows.

 RowSize

 Integer

 Gets or sets default size (height) of rows in grid.

 Row[i]

 TRow

 Access to additional properties of a row by its index. More info.

 RowVisible[i]

 Boolean

 Determines the visibility of the row by its index.

 Selected[i]

 Boolean

 Gets or sets specified row's selected state.

 SelectedRow

 Integer

 Gets or sets selected Row's Index.

 SelectedColumn

 Integer

 Gets or sets Index of selected Column.

 SelectedCount

 Integer

 Gets number of selected rows.

 ShowHint

 Boolean

 Specifies whether to show the Help Hint when the mouse pointer moves over the component, see also Hint

 TabOrder

 Integer

 Indicates the position of the component in its parent's tab order. TabOrder is the order in which child components are visited when the user presses the Tab key.

 TabStop

 Boolean

 Determines whether the user can tab to a control. Use the TabStop to allow or disallow access to the control using the Tab key.

 Tag

 Integer

 Allows you to assign a number to a component for your own needs.

 TagString

 String

 Allows you to assign a string to a component for your own needs.

 VertScrollBar

 TNxScrollBar

 Property to access additional scrollbar properties and methods. More info.

 Visible

 Boolean

 Specifies whether the component appears onscreen.

 VisibleRows

 Integer

 Gets number of visible rows.

 Left

 Integer

 Specifies the horizontal coordinate of the left edge of a component relative to its parent.

 Top

 Integer

 Specifies the vertical coordinate of the upper-left of a component relative to its parent.

 Width

 Integer

 Specifies the horizontal size of the component in pixels.

 Height

 Integer

 Specifies the vertical size of the component in pixels.






Methods

 Method

 Description

 function dbIndexToID (index: Integer): integer

 Allows you to get the record ID (database field id) by specifying the row number.

 function dbUpdate: String

 Forcibly updates data in the component. As a rule, the component updates data automatically if the data has been changed.  It also returns the SQL query that was used to access the database.

 function AddRow (Count: Integer = 1): Integer

 Adds the specified number of rows to the component. Returns the index of the last added row. The data is not added to the database.

 procedure AddChildRow (const Index: Integer; Position: TChildRowPosition)

 Adds a child branch for the specified row. No data will be added to the database. Available values of the Position parameter: crFirst, crLast

 procedure BeginUpdate

 Called before performing a large number of operations on a component to increase performance. The EndUpdate method must be called at the end.

 procedure BestFitColumns (BestFitMode: TBestFitMode = bfCells)

 The method automatically adjusts the width of the columns. More info.

 procedure BestFitRow (const Index: Integer)

 The method automatically adjusts the height of the row, depending on the contents of the cells in the given row. More info.

 procedure CalculateFooter (VisibleOnly: Boolean = False)

 Calculates footer of the component.

 procedure ClearRows

 Clears rows of of the component.

 procedure CollapseAll

 It collapses all the nodes of the component.

 procedure DeleteRecord (id: integer)

 Deletes the record with the specified identifier, with all its child nodes.

 procedure DeleteRow (Index: Integer)

 Deletes specified row. The record from the database will not be deleted.

 function ExportToExcel (FileName: string = ''; ExcelVisible: boolean = True; FirsRowColumns: boolean = True): Variant

 Exports data from the component to Excel. Also returns an OLE Excel object, to work with the data later.

 function ExportToLibreCalc (FirsRowColumns: boolean = True): Boolean

 Exports data from the component to OpenOffice (LibreOffice).

 procedure EndUpdate

 See BeginUpdate

 procedure ExpandNode (Index: Integer)

 Expands the specified node of the component.

 procedure ExpandAll

 Expands all the nodes of the component.

 function GetRowAtPos (X, Y: Integer): Integer

 Allows you to get the row index by coordinates.

 function GetColumnAtPos (X, Y: Integer): TNxCustomColumn

 Allows you to get a link to a column by coordinates.

 function GetChildCount (const Index: Integer; Recurse: Boolean = True): Integer

 Returns the number of child records for the specified row in the Index parameter.

 function GetFirstChild (const Index: Integer): Integer

 Returns the index of the first child row relative to the row specified in the Index parameter.

 function GetLastChild (const Index: Integer): Integer

 Returns the index of the last child row relative to the row specified in the Index parameter.

 function GetLevel (const Index: Integer): Integer

 Returns the nesting level of the specified row.

 function GetNextSibling (const Index: Integer): Integer

 Returns the index of the next row on the same level. If there is no next row on the same level, it returns -1.

 function GetParent (const Index: Integer): Integer

 Returns the index of the row that is the parent.

 function GetPrevSibling (const Index: Integer): Integer

 Returns the index of the previous row on the same level. If there is no previous row on the same level, it returns -1.

 function HasChildren (const Index: Integer): Boolean

 Allows you to find out if there are child records for the specified row.

 procedure InsertRow (Pos: Integer; Count: Integer = 1)

 Inserts single row at specified position. This will not add an record to the database.

 procedure LoadFromTextFile (const FileName: String; Separator: Char = ','; MultiLineSeparator: Char = '|'; StartRow: Integer = 0)

 Loads text file data into the component. The data will not get into the database. The encoding of the loaded file must be Unicode (UCS-2 Little Endian)

 procedure MoveRow (FromPos, ToPos: Integer)

 Moves row from specified position to another one. In this case, no changes are made to the database.

 procedure SaveToHtml (FileName: String; SaveHeaders: boolean = True; AllRows: boolean = False; CreateStyleSheet: boolean = True; SaveFooter: boolean = False; SaveCaption: boolean = False)

 Saves the content of the component in an HTML file.

  procedure SaveToTextFile (const FileName: String; Separator: Char = ','; MultiLineSeparator: Char = '|')

 Saves the contents of the component to a text file. The file encoding used is Unicode (UCS-2 Little Endian).

 procedure ScrollToRow (index: integer)

 Moves the scroll in the component so that the specified line is visible.

 procedure SelectAll

 Selects all rows in the component. For the method to work, the Options property must have values goMultiSelect and goSelectFullRow.

 procedure SelectRange (FromRow, ToRow: Integer; Value: Boolean)

 Selects (or deselects, if Value = False) the specified range of rows.

 procedure SetFocus

 Gives the input focus to the component.

 procedure SwapRows (FromPos, ToPos: Integer)

 Swaps positions of two rows.






Events

 Event

 Description

 OnAfterSort (Sender: TObject; ACol: Integer)

 Occurs after the column is sorted.

 OnCellClick (Sender: TObject; ACol, ARow: Integer)

 Occurs when the user clicks on a cell. More info.

 OnCellDoubleClick (Sender: TObject; ACol, ARow: Integer)

 Occurs when the user double-clicks a cell.

 OnChange (Sender: TObject)

 Occurs after the component has been populated with data from the database.

 OnClick (Sender: TObject)

 Occurs when the user clicks the component.

 OnColumnResize (Sender: TObject; ACol: Integer)

 Occurs when the user resize the column.

 OnDoubleClick (Sender: TObject)

 Occurs when the user double-clicks the left mouse button when the mouse pointer is over the component.

 OnEnter (Sender: TObject)

 Occurs when a component receives the input focus.

 OnExit (Sender: TObject)

 Occurs when the input focus shifts away from one component to another.

 OnExpand (Sender: TObject; ARow: Integer)

 Occurs when a node expands or collapses.

 OnFooterClick (Sender: TObject; ACol: Integer)

 Occurs when the user clicks on the footer.

 OnHeaderClick (Sender: TObject; ACol: Integer)

 Occurs when the user clicks on a column header.

 OnHeaderDoubleClick (Sender: TObject; ACol: Integer)

 Occurs when the user double-clicks a column header.

 OnInputSelectCell (Sender: TObject; ACol: Integer)

 Occurs when the user has moved to the input field.

 OnKeyDown (Sender: TObject; var Key: Word; Shift, Alt, Ctrl: boolean)

 Occurs when a user presses any key while the form has focus.

 OnKeyPress (Sender: TObject; var Key: Char)

 Occurs when a key is pressed. Note that this procedure handles printable characters only.

 OnKeyUp (Sender: TObject; var Key: Word; Shift, Alt, Ctrl: boolean)

 Occurs when the user releases a key that was pressed.

 OnLoadProgress (Sender: TObject; ACol, ARow: Integer)

 Occurs when a text file is loaded into a component using the LoadFromTextFile method

 OnMouseDown (Sender: TObject; MouseLeft, MouseRight, MouseMiddle: boolean; Shift, Alt, Ctrl: boolean; X, Y: Integer)

 Occurs when the user presses a mouse button with the mouse pointer over a component.

 OnMouseEnter (Sender: TObject)

 Occurs when the user moves the mouse into a component.

 OnMouseLeave (Sender: TObject)

 Occurs when the user moves the mouse outside of a component.

 OnMouseMove (Sender: TObject; Shift, Alt, Ctrl: boolean; X, Y: Integer)

 Occurs when the user moves the mouse pointer while the mouse pointer is over a component.

 OnMouseUp (Sender: TObject; MouseLeft, MouseRight, MouseMiddle: boolean; Shift, Alt, Ctrl: boolean; X, Y: Integer)

 Occurs when the user releases a mouse button that was pressed with the mouse pointer over a component.

 OnResize (Sender: TObject)

 Occurs when a component is resized.

 OnRowMove (Sender: TObject; FromPos, ToPos: Integer; var Accept: Boolean)

 Occurs when the user has moved a row to a new position. Allows you to cancel the move. More info.

 OnSortColumn (Sender: TObject; ACol: Integer; Ascending: Boolean)

 Occurs before the column is sorted.

 OnDropFiles (Sender: TObject; ArrayOfFiles: array of string; X, Y: Integer)

 Occurs when user tries to drag and drop a file from explorer to a form. More info.