Description


The component is used to output records from the database in tabular form.



Class: TdbStringGridEx



Properties

 Property

 Type

 Description

 dbCustomOrderBy

 String

 Allows you to specify sorting. For example, you can specify sorting by two database fields at the same time, example: tablename.fieldname1, tablename.fieldname2 или tablename.fieldname1 ASC, tablename.fieldname2 DESC

 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

 dbGeneralTable

 String

 Contains the name of the main database table; it is from this table that you get the identifier (database field id) of the selected record using the dbItemID or sqlValue property. The property can also contain an external key, for example, when a component is used for a search.

 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.

 dbLimit

 Integer

 Allows you to set the maximum number of records that will be populated into a component. More info.

 dbListFieldsNames

 String

 Contains header names for columns separated by commas.

 dbOffSet

 Integer

 Allows you to set an offset when retrieving records from the database. More info.

 dbParentTable

 String

 Contains the name of the parent database table when the component displays child records (option: Show Child Records).

 dbParentTableId

 Integer

 Contains the identifier (id field) of the parent record in the parent table (dbParentTable) when the component displays child records (option: Show child records).

 dbPopupMenu

 TPopupMenu

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

 dbSortAsc

 Boolean

 If True, the records will be sorted in ascending order, otherwise in descending order. The property value will be ignored if a different sorting is specified in the dbCustomOrderBy property.

 dbSortField

 String

 The database field by which the records in the component will be sorted. The property value will be ignored if a different sorting is specified in the dbCustomOrderBy property.

 dbSQL

 String

 Contains an SQL query if the component was populated with data using the button with the "SQL query" action. Also allows you to set your own SQL query which will be executed when calling the dbSQLExecute method. 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

 пример: SQLExecute ('INSERT INTO tablename (fieldname) VALUES ('+Form1.TableGrid1.sqlValue+')');

 AllowCreate

 Boolean

 It is responsible for the ability to create new records directly in the component.

 AllowCreateEmpty

 Boolean

 It is responsible for the ability to create new empty records.

 AllowEdit

 Boolean

 It is responsible for the ability to edit records directly in the component.

 AllowDelete

 Boolean

 It is responsible for the ability to delete records directly in the component.

 SecondClickEdit

 Boolean

 Determines whether or not you need to double-click a cell to edit a record.

 BorderStyle

 TBorderStyle

 Determines whether the component has a border. Available values: 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.TableGrid1.CanFocus then Form1.TableGrid1.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.

 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

 SlideSize

 Integer

 Gets or sets size (height) of single slide. Имеет смысл, когда свойство компонента GridStyles = gsSlides. Подробней про режим gsSlides.

 SortedColumn

 TNxCustomColumn

 Reference to the sorted column.

 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 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 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

 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.

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

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

 procedure MoveRow (FromPos, ToPos: Integer)

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

 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 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 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 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

 OnApplyEditText (Sender: TObject; ACol, ARow: Integer; var Value: String)

 Occurs when you finish editing a cell. Allows you to change the entered value. More info.

 OnAfterEdit (Sender: TObject; ACol, ARow: Integer; Value: String)

 Occurs when the cell editing is successfully completed. More info.

 OnAfterRowMove (Sender: TObject; FromPos, ToPos: Integer)

 Occurs when the user has successfully moved the row to a new position.

 OnAfterSort (Sender: TObject; ACol: Integer)

 Occurs after the column is sorted.

 OnBeforeEdit (Sender: TObject; ACol, ARow: Integer; var Accept: Boolean)

 Occurs before the cell enters edit mode. Allows you to disable editing. More info.

 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.

 OnEditAccept (Sender: TObject; ACol, ARow: Integer; Value: String; var Accept: Boolean)

 Occurs when the user has finished editing a cell, such as selecting another cell or pressing Enter. Allows you to reject the entered value. More info.

 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.

 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.

 OnInputAccept (Sender: TObject; var Accept: Boolean)

 Occurs before a new record is added from the input line. Allows you to cancel the creation of a new record. More info.

 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.