ThTable
Represents a single data table instance linked to a schema definition.Provides access to field values, schema metadata, and runtime state for the currently loaded record.
Supports translation, validation, and interaction with the underlying storage or UI bindings.
This class is typically used for working with a single logical record within a structured schema table.
ThTable Public Variables
Variable | Description |
---|---|
Modified_By_User |
Indicates whether the record was modified by user interaction. This flag is used to detect changes for save or validation triggers. |
rt_Update_Parent_List |
Reference to a parent ThTable used during runtime updates. When set, new records will be appended to the parent list if the key does not already exist. |
rt_SB_Msg_Ptr |
Pointer to a status bar messaging structure associated with this table. Used to display runtime feedback or processing status in the UI. |
rt_DutyLevel2 |
Enables or marks duty-level-2 behavior for the current record. This flag is typically used for advanced filtering or field display conditions. |
rt_Duty_Fields_Inc_Bool |
When True , includes boolean fields in the duty field processing logic. Used internally by procedures like Duty_Fields_Verified or field exclusion logic. |
GlobalInit
Initializes the table instance and prepares internal state variables. This method is intended to be overridden by descendants and is called during setup.procedure GlobalInit; virtual;
Set_Other_Language_Then_Default
Applies a translation language to the table different from the default system language.Optionally updates visual controls to reflect the selected language immediately.
procedure Set_Other_Language_Then_Default(Language: ThTranslation_Language; UpdateControls: Boolean = True);
Parameters
- Language: ThTranslation_Language; The language to apply to the table.
- UpdateControls: Boolean; If
True
, visual components are refreshed with new translations.
Language
Returns the currently active translation language for the table. Used to determine which caption or value translations are applied to fields.function Language: ThTranslation_Language;
Return Value
Returns theThTranslation_Language
currently in effect for this table instance.Clear
Clears all data in the current record and resets all fields to their default values.Used to initialize or reset the table before adding or editing a record.
procedure Clear;
Empty
Checks whether the current table is empty. You can optionally check from a specific field index onward.function Empty(FromCol: Integer = -1): Boolean;
Parameters
- FromCol: Integer; Starting field index to check for non-empty values (default is -1 = full record).
Return Value
ReturnsTrue
if the record is empty.Returns
False
if any field contains a value.Insert
Inserts the new record at a specific row position in the dataset. This shifts existing rows as needed to accommodate the new entry.procedure Insert(TargetRow: Integer);
Parameters
- TargetRow: Integer; The row index where the new record should be inserted.
Add
Adds the new record to the table. If the table already contains records, the new record will always be appended to the end.If the table is empty, the record will only be added if
Append
is True
.procedure Add(CONST Append: Boolean = False);
Parameters
- Append: Boolean; If
False
, in case table is empty the new record was not added; otherwise appends the new record anyway.
DeleteRange
Deletes a range of records from the table between the specified indexes. Both boundary indexes are inclusive.function DeleteRange(Top, Bottom: Integer): Boolean;
Parameters
- Top: Integer; Index of the first row to delete.
- Bottom: Integer; Index of the last row to delete.
Return Value
ReturnsTrue
if records were deleted.Returns
False
if the range was invalid or empty.Delete_Selection_Range
Deletes the currently selected range of rows from the table. Selection must be pre-defined using the table's selection mechanism.function Delete_Selection_Range: Boolean;
Return Value
ReturnsTrue
if any rows were deleted from the selection.Returns
False
if no selection was defined or deletion failed.Delete
Deletes records from the table that match the given key condition.Field names, values, and logic type (AND/OR) are used to build the deletion filter.
function Delete(CONST FldNames: ThFlds_Name_Array; CONST KeyStr: ThFlds_Name_Array; CONST KeyNum: Array of ThNumeric;
CONST Logic: Thds_Logic = he_AND): Boolean;
Parameters
- FldNames: ThFlds_Name_Array; Array of field names to compare.
- KeyStr: ThFlds_Name_Array; Array of string values used for matching (optional if using
KeyNum
). - KeyNum: Array of ThNumeric; Array of numeric values used for matching.
- Logic: Thds_Logic; Logic mode (
he_AND
orhe_OR
) for combining field conditions.
Thds_Logic = (he_AND, he_OR, he_AND_NOT, he_OR_NOT);
Return Value
ReturnsTrue
if one or more records were deleted based on the filter.Delete_Empty_Records
Deletes all records that are completely empty starting from a specified column index.Useful for cleaning up unused or placeholder rows.
function Delete_Empty_Records(FromCol: Integer = -1): Boolean;
Parameters
- FromCol: Integer; Optional starting column index to check for emptiness (default is -1 = full row check).
Return Value
ReturnsTrue
if any empty records were deleted.Returns
False
if no deletions occurred.Search
Searches the table for a record that matches the given set of field values. This overload allows multi-field matching using arrays of names and values.function Search(CONST FldNames: ThFlds_Name_Array; CONST KeyStr: ThFlds_Name_Array;
CONST KeyNum: Array of ThNumeric): Boolean;
Parameters
- FldNames: ThFlds_Name_Array; Field names to search on.
- KeyStr: ThFlds_Name_Array; String values to compare (optional if using
KeyNum
). - KeyNum: Array of ThNumeric; Numeric values to compare against fields.
Return Value
ReturnsTrue
if a matching record was found. In this case the current row pointer moves to the first match found.Returns
False
otherwise.Search
Searches the table for a record that matches a value in a specific column. This overload simplifies searching by a single column index.function Search(CONST Column: Integer; CONST KeyStr: String; CONST KeyNum: ThNumeric): Boolean;
Parameters
- Column: Integer; Index of the column to search.
- KeyStr: String; String value to match.
- KeyNum: ThNumeric; Numeric value to match.
Return Value
ReturnsTrue
if a match is found in the specified column. In this case the current row pointer moves to the first match found.Returns
False
otherwise.SearchRow
Searches for the row index of the first record matching the specified field values.This overload allows searching across multiple fields using arrays of names and values.
function SearchRow(CONST FldNames: ThFlds_Name_Array; CONST KeyStr: ThFlds_Name_Array;
CONST KeyNum: Array of ThNumeric): Integer;
Parameters
- FldNames: ThFlds_Name_Array; Array of field names to search.
- KeyStr: ThFlds_Name_Array; Array of string values to compare.
- KeyNum: Array of ThNumeric; Array of numeric values to compare.
Return Value
Returns the index of the matching row.Returns
-1
if no match is found.SearchRow
Searches for the row index where a single column matches a given value.This overload is optimized for column-based matching with an optional search starting point.
function SearchRow(CONST Column: Integer; CONST KeyStr: String; CONST KeyNum: ThNumeric;
CONST Start_From_CurrRow: Boolean = False): Integer;
Parameters
- Column: Integer; Index of the column to search.
- KeyStr: String; String value to match.
- KeyNum: ThNumeric; Numeric value to match.
- Start_From_CurrRow: Boolean; If
True
, the search begins from the current row instead of the first.
Return Value
Returns the index of the matching row.Returns
-1
if no match is found.Search_ABC_Fast
Performs a fast search for a record matching the specified string value in a named field.Optimized for sorted or alphabetically indexed tables. Can optionally move the current row pointer to the matched result.
function Search_ABC_Fast(CONST FldName: String; CONST KeyStr: String; CONST SetRow: Boolean = False): Integer;
Parameters
- FldName: String; The name of the field to search.
- KeyStr: String; The string value to search for.
- SetRow: Boolean; If
True
, sets the current row to the found index.
Return Value
Returns the index of the matching row if found.Returns
-1
if no match is found.Search_ABC_Fast
Performs a fast search for a string value within a specific column index. Optimized for alphabetically sorted data and supports optional row selection.function Search_ABC_Fast(CONST Column: Integer; CONST KeyStr: String; CONST SetRow: Boolean = False): Integer;
Parameters
- Column: Integer; Index of the column to search.
- KeyStr: String; The string to look for.
- SetRow: Boolean; If
True
, moves the current row to the found record.
Return Value
Returns the index of the matching row if found.Returns
-1
if no match is found.Replace
Searches for and replaces values within a specific column of the table.This is an overloaded function that can operate on either string or numeric data types.
The operation can be limited to a specific range of rows.
Function Replace(FldName: String; FindVal, NewVal: String; Method: ThReplaceMethod; FromRow: Integer = 0; UntilRow: Integer = -1): Boolean; Overload;
Function Replace(FldName: String; FindVal, NewVal: ThNumeric; FromRow: Integer = 0; UntilRow: Integer = -1): Boolean; Overload;
Parameters
- FldName: String; The name of the field (column) in which to perform the replacement.
- FindVal: String or ThNumeric; The text or numeric value to search for.
- NewVal: String or ThNumeric; The text or numeric value to replace the found value with.
- Method: ThReplaceMethod; (String overload only) The replacement strategy, such as `he_WholeValue` or `he_ContString`.
ThReplaceMethod
is an enumerated type, not a class, used by theThTable.Replace
function to define the strategy for replacing string data within a table's column.
Method Description he_WholeValue Replaces the cell's entire content only if it exactly matches the FindVal
string.he_ContString Replaces all occurrences of the FindVal
substring within the cell's text.he_Override Unconditionally replaces the entire content of the cell with the NewVal
string, regardless of its original value.he_GroupItem Treats the cell's content as a multi-line list and replaces only the specific list item that exactly matches FindVal
. - FromRow: Integer; The starting row for the operation (default is 0).
- UntilRow: Integer; The ending row for the operation (default is -1, which means the last row).
Return Value
Returns `True` if at least one replacement was made, otherwise `False`.SameStr
Performs a case-insensitive comparison between the text in a specified cell and a given string.This is an overloaded function that can identify the cell by either its column and row index or by its field name and row index.
If a negative row index is provided, the table's current row is used.
Function SameStr(CONST ColNum, Y: Integer; CONST Str2: String): Boolean; Overload;
Function SameStr(CONST FldName: String; CONST Y: Integer; CONST Str2: String): Boolean; Overload;
Parameters
- ColNum: Integer; The zero-based index of the column to check.
- FldName: String; The name of the field to check.
- Y: Integer; The zero-based index of the row to check. A negative value refers to the current row.
- Str2: String; The string to compare against the cell's value.
Return Value
Returns `True` if the cell's text is identical to `Str2` (case-insensitive).Returns `False` otherwise.
SameValue
Compares the values of two cells in the same column but on different rows to determine if they are identical.This is an overloaded function that can identify the column by either its index or field name.
The comparison logic is type-aware, correctly handling strings, numbers, and dates.
Function SameValue(CONST FldName: String; CONST Y1, Y2: Integer; CONST Case_Sensitive: Boolean = False): Boolean; Overload;
Function SameValue(CONST ColNum: Integer; CONST Y1, Y2: Integer; CONST Case_Sensitive: Boolean = False): Boolean; Overload;
Parameters
- FldName: String; The name of the field (column) to compare.
- ColNum: Integer; The zero-based index of the column to compare.
- Y1: Integer; The row index of the first cell.
- Y2: Integer; The row index of the second cell.
- Case_Sensitive: Boolean; (String fields only) If `True`, the string comparison will be case-sensitive (default is `False`).
Return Value
Returns `True` if the values in both cells are identical.Returns `False` otherwise.
Column_Data_Into_StringList_NO_Dups
Extracts all unique, non-empty values from a specified column and populates an existing `ThStringList` object with them.
Procedure Column_Data_Into_StringList_NO_Dups(CONST FieldName: String; SL: ThStringList);
Parameters
- FieldName: String; The name of the field (column) from which to extract data.
- SL: ThStringList; The `ThStringList` instance that will be populated with the unique values.
Column_Data_Into_New_StringList_NO_Dups
Creates and returns a new `ThStringList` object containing all unique, non-empty values from a specified column.This is a convenience function that handles the creation of the list for you.
Function Column_Data_Into_New_StringList_NO_Dups(CONST FieldName: String): ThStringList;
Parameters
- FieldName: String; The name of the field (column) from which to extract data.
Return Value
Returns a new `ThStringList` object containing the unique values.Returns `NIL` if the column does not exist or if the table is empty.
Column_Data_As_String_List
Returns the data from a specified column as a single string, with each value separated by a CRLF (`#13#10`).The function provides an option to either include all values or only unique values.
Function Column_Data_As_String_List(CONST FieldName: String; CONST Prevent_Duplicities: Boolean = False): String;
Parameters
- FieldName: String; The name of the field (column) to read.
- Prevent_Duplicities: Boolean; If `True`, the returned string will contain only unique values from the column. The default is `False`.
Return Value
Returns a multi-line string containing the data from the column.SumColumn
Calculates the sum of all numeric values within a specified column.This is an overloaded function that can identify the column by either its field name or its index.
The calculation can be limited to a specific range of rows.
If the specified column is a string type, the function will return `1` if any cell in the range contains text, and `0` otherwise.
Function SumColumn(FieldName: String; FromRow: Integer = -1; UntilRow: Integer = -1): Double; Overload;
Function SumColumn(Column: Word; FromRow: Integer = -1; UntilRow: Integer = -1): Double; Overload;
Parameters
- FieldName: String; The name of the field (column) to sum.
- Column: Word; The zero-based index of the column to sum.
- FromRow: Integer; The starting row for the calculation (default is -1, meaning the first row).
- UntilRow: Integer; The ending row for the calculation (default is -1, meaning the last row).
Return Value
Returns a `Double` representing the total sum of the values in the specified column and row range.Column_Statistics
Computes a set of statistical values for a specified numeric column over a given range of rows.This is an overloaded function that can identify the column by its field name or index.
The results are returned in a `TH_Column_Statistics` record.
This function only operates on numeric data types and will not process string-based columns.
Function Column_Statistics(FieldName: String; FromRow: Integer = -1; UntilRow: Integer = -1): TH_Column_Statistics; Overload;
Function Column_Statistics(Column: Word; FromRow: Integer = -1; UntilRow: Integer = -1): TH_Column_Statistics; Overload;
Parameters
- FieldName: String; The name of the field (column) for which to calculate statistics.
- Column: Word; The zero-based index of the column for which to calculate statistics.
- FromRow: Integer; The starting row for the calculation (default is -1, meaning the first row).
- UntilRow: Integer; The ending row for the calculation (default is -1, meaning the last row).
Return Value
Returns a `TH_Column_Statistics` record containing the calculated data.
TH_Column_Statistics
is a record (structure) that holds the results returned by the ThTable.Column_Statistics
function.
It contains all the key statistical metrics calculated for a numeric table column.
Field | Description |
---|---|
Data_OK | A `Boolean` flag that is `True` if the statistics were calculated successfully on a numeric column. |
Data_Type | The `ThDataType` of the column that was analyzed. |
Sum | A `Double` representing the total sum of all values in the specified range. |
Min | A `Double` representing the minimum value found in the range. |
Max | A `Double` representing the maximum value found in the range. |
Avg | A `Double` representing the average of the values in the range. |
Sum_Positive_Values | A `Double` representing the sum of only the positive values. |
Sum_Negative_Values | A `Double` representing the sum of only the negative values. |
Not_Zero_Counter | An `Integer` counting how many values in the range were not zero. |
X_IRR
Calculates the internal rate of return (IRR) for a schedule of cash flows that are not necessarily periodic.This function is analogous to the XIRR function in spreadsheet applications.
Function X_IRR(CONST DatesCol, ValuesCol: Word; CONST Guess: Double = 0): Double;
Parameters
- DatesCol: Word; The index of the column containing the dates of the cash flows.
- ValuesCol: Word; The index of the column containing the corresponding cash flow amounts.
- Guess: Double; An optional estimate for the expected IRR (default is 0).
Return Value
Returns a `Double` representing the internal rate of return for the specified series of cash flows.Duplicity_Exists
Checks if a value in a specific cell exists elsewhere in the same column.The function performs a case-insensitive search for strings and a type-aware comparison for numeric values.
It will not check for duplicates of empty cells.
Function Duplicity_Exists(FieldName: String; OnRow: Integer): Boolean;
Parameters
- FieldName: String; The name of the column to check for duplicate values.
- OnRow: Integer; The row index of the cell to check. If a negative value is provided, the table's current row is used.
Return Value
Returns `True` if a duplicate value is found in another row within the same column; otherwise, it returns `False`.Duplicity
Finds and handles duplicate rows based on the values in one or more specified columns.The table is first sorted by the `FieldsList` to group identical rows together for comparison.
The action taken is determined by the `Command` parameter.
Function Duplicity(CONST Command: ThDuplicity_ToDo; CONST FieldsList: ThFlds_Name_Array): Boolean;
Parameters
- Command: ThDuplicity_ToDo; The action to perform. It can be one of the following values:
he_Check_IF_Dup_Exist
: Scans the table for duplicates without modifying it.he_Remove_Dups_From_2nd_Row
: Deletes all duplicate rows, keeping only the first occurrence of each unique record.he_Leave_All_Dups_Rows
: Deletes all unique rows, keeping only the records that have duplicates.
- FieldsList: ThFlds_Name_Array; An array of field names to use for the comparison. If this array is empty, the table's last used sort order is used.
Return Value
Returns `True` if any duplicate rows were found based on the specified criteria.Set_Column_Value
Sets all cells within a specified column and row range to a single value.This is an overloaded procedure that can assign either a `String` or a `ThNumeric` value.
Procedure Set_Column_Value(FldName: String; NewVal: String; FromRow: Integer = -1; UntilRow: Integer = -1); Overload;
Procedure Set_Column_Value(FldName: String; NewVal: ThNumeric; FromRow: Integer = -1; UntilRow: Integer = -1); Overload;
Parameters
- FldName: String; The name of the field (column) to modify.
- NewVal: String or ThNumeric; The new value to assign to all cells in the range.
- FromRow: Integer; The starting row for the operation (default is -1, meaning the first row).
- UntilRow: Integer; The ending row for the operation (default is -1, meaning the last row).
Set_Column_Unique_TS
Populates a column with unique timestamps, typically with millisecond precision.This is useful for creating unique identifiers or logging the creation time of records.
Procedure Set_Column_Unique_TS(FldName: String; Action: GUTS_Action; Use_UTC: Boolean; Subkey_To_Col0: Boolean = False);
Parameters
- FldName: String; The name of the timestamp field (column).
- Action: GUTS_Action; The operation to perform. It can be one of the following:
he_Just_New_Records
: Fills only empty rows with new timestamps.he_Override_Column
: Overwrites the entire column with new timestamps.he_Fix_Millisec_All_Rows
: Re-calculates only the millisecond part of existing timestamps to ensure uniqueness after sorting or grouping.
- Use_UTC: Boolean; If `True`, the base time used is UTC. If `False`, it's the local server time.
- Subkey_To_Col0: Boolean; If `True`, the millisecond counter is reset whenever the value in the first column (column 0) changes. This generates unique timestamps within groups.
Set_Column_Numerator
Fills a column with a sequence of incrementing integers, like an auto-number field.The operation can be performed on a specific range of rows.
Procedure Set_Column_Numerator(FldName: String; CONST StartFrom: Cardinal; Subkey_To_Col0: Boolean; FromRow: Integer = -1; UntilRow: Integer = -1);
Parameters
- FldName: String; The name of the field (column) to number.
- StartFrom: Cardinal; The integer value to start the sequence from.
- Subkey_To_Col0: Boolean; If `True`, the numerator resets to `StartFrom` whenever the value in the first column (column 0) changes, creating numbered sequences within groups.
- FromRow: Integer; The starting row for the operation (default is -1, meaning the first row).
- UntilRow: Integer; The ending row for the operation (default is -1, meaning the last row).
ResetFlagColumn
Sets the internal boolean `Flag` for every cell in a specified column to a single value.This is an overloaded procedure that can identify the column by either its name or its index.
This is often used to mark or unmark a set of rows for a subsequent batch operation.
Procedure ResetFlagColumn(ColNum: Integer; FlagState: Boolean); Overload;
Procedure ResetFlagColumn(FldName: String; FlagState: Boolean); Overload;
Parameters
- ColNum: Integer; The zero-based index of the column whose flags will be reset.
- FldName: String; The name of the field (column) whose flags will be reset.
- FlagState: Boolean; The value to assign to the flag of every cell in the column (`True` to set, `False` to clear).
Zebra_Flag
Sets the internal cell `Flag` property to create patterns for UI purposes, such as zebra-striping or identifying single-item groups.For this procedure to work correctly, the table should be sorted by the `Grouping_Column` beforehand.
Procedure Zebra_Flag(CONST Grouping_Column, Zebra_Flag_Col, Single_In_Group_Flag_Col: Integer);
Parameters
- Grouping_Column: Integer; The index of the column that defines the groups.
- Zebra_Flag_Col: Integer; The index of the column where an alternating `True`/`False` flag will be stored for each group, creating a zebra-stripe pattern.
- Single_In_Group_Flag_Col: Integer; The index of an optional column where the flag will be set to `True` only for rows that are the single member of their group.
Round_Money_Cols_Data
Rounds the numeric values in all columns of type `he_Money` to the standard monetary precision.
Procedure Round_Money_Cols_Data(AccurateMask: Boolean = False; All_Table: Boolean = True);
Parameters
- AccurateMask: Boolean; A flag that is passed to the underlying rounding function to control its precision (default is `False`).
- All_Table: Boolean; If `True` (default), the procedure rounds all rows in the money columns. If `False`, it only rounds the values in the current row.
SwitchRows
Swaps the entire contents of two specified rows within the table.
Procedure SwitchRows(CONST Row1, Row2: Integer);
Parameters
- Row1: Integer; The index of the first row to be swapped.
- Row2: Integer; The index of the second row to be swapped.
Copy_Row
Copies the data from a single row in a source table to a single row in the current (target) table.The procedure intelligently matches columns by field name, and can optionally fall back to matching by their visual captions.
Procedure Copy_Row(Source: ThTable; SourceRow, TargetRow: Integer; Try_Copy_By_VisualName: Boolean = True);
Parameters
- Source: ThTable; The table from which to copy the row.
- SourceRow: Integer; The index of the row to copy from the source table.
- TargetRow: Integer; The index of the row in the current table where the data will be pasted.
- Try_Copy_By_VisualName: Boolean; If `True` (default), and a column cannot be matched by its `Name`, the procedure will attempt to match it based on its `VisualName`.
Copy_Table
Copies records from a source table into the current table.It can either append the records or completely overwrite the existing data.
Procedure Copy_Table(Source: ThTable; Append_Mode, Try_Copy_By_VisualName: Boolean; Append_By_Key: String = '');
Parameters
- Source: ThTable; The table from which to copy the records.
- Append_Mode: Boolean; If `True`, records from the source table are added to the end of the current table. If `False`, the current table is cleared before copying.
- Try_Copy_By_VisualName: Boolean; Passed to the internal `Copy_Row` calls, allowing column matching by visual name.
- Append_By_Key: String; An optional key value. If provided, only rows from the source table where the first column matches this key will be copied.
Sort
Sorts the table's rows based on the values in one or more columns.The sort order and behavior can be customized using special prefixes in the field names.
Procedure Sort(CONST SortList: ThFlds_Name_Array; KeepRecordPointer: Boolean = False; ClearSortArray: Boolean = False);
Parameters
- SortList: ThFlds_Name_Array; An array of strings specifying the field names to sort by. The order of fields determines the sort priority.
Special prefixes can be used:
@
: Sorts by the cell's boolean `Flag` value instead of its data.!
: Sorts the column in descending order.~
: Sorts by absolute value for numbers or performs a case-sensitive sort for strings.
- KeepRecordPointer: Boolean; If `True`, the current row pointer is maintained on the same record after the sort is completed (default is `False`).
- ClearSortArray: Boolean; If `True`, the internal sort criteria are cleared after the operation finishes (default is `False`).
Find_And_Handle_Rows_Group_By_Events
Processes the table to identify groups of identical adjacent rows and triggers events to handle them.For this procedure to work correctly, the table must be sorted first.
It relies on two developer-defined events: `OnCompare_Rows` to determine if two rows belong to the same group, and `OnHandle_Rows_Group` which is fired for each complete group found.
Procedure Find_And_Handle_Rows_Group_By_Events;
Duty_Fields_Verified
Validates the table to ensure that all fields marked as mandatory in the schema are filled.It checks all rows and considers both individual duty fields and duty groups (where at least one field in a group must have a value).
Function Duty_Fields_Verified(Notify_User: Boolean = True; AllowEmpty: Boolean = False): Boolean;
Parameters
- Notify_User: Boolean; If `True` (default), a popup message will be shown to the user if a mandatory field is empty.
- AllowEmpty: Boolean; If `True`, the function will return `True` without checking if the table is completely empty.
Return Value
Returns `True` if all mandatory fields in all rows are filled, otherwise returns `False`.Duty_Fields_Verified_Exclude
Performs the same validation as `Duty_Fields_Verified` but allows specific mandatory fields to be ignored for this check.
Function Duty_Fields_Verified_Exclude(Exclude_Fields: ThFlds_Name_Array; Notify_User, AllowEmpty, JumpToRow: Boolean): Boolean;
Parameters
- Exclude_Fields: ThFlds_Name_Array; An array of field names that should be excluded from the validation check.
- Notify_User: Boolean; If `True`, a popup message will be shown to the user upon validation failure.
- AllowEmpty: Boolean; If `True`, the function will succeed without checking if the table is empty.
- JumpToRow: Boolean; If `True` and validation fails, the table's cursor will be moved to the first row containing an error.
Return Value
Returns `True` if all relevant mandatory fields are filled, otherwise returns `False`.Verify_Custom_Duty_FldsList
Validates a custom list of fields to ensure they have values, but only for the currently selected row.This function is useful for validating a form or a specific part of a record without relying on the schema's duty field properties.
Function Verify_Custom_Duty_FldsList(DutyFields: ThFlds_Name_Array; Notify_User: Boolean = False; AllowEmpty: Boolean = False): Boolean;
Parameters
- DutyFields: ThFlds_Name_Array; An array of field names to check for values on the current row.
- Notify_User: Boolean; If `True` (default), a popup message will be shown upon validation failure.
- AllowEmpty: Boolean; If `True`, the function will succeed without checking if the table is empty.
Return Value
Returns `True` if all fields in the `DutyFields` list have a value on the current row.Returns `False` otherwise.
ICell_Inc
Increments the integer value of a specific cell, identified by its column and row index.
Procedure ICell_Inc(CONST X, Y: Integer; CONST IncValue: Int64);
Parameters
- X: Integer; The zero-based column index of the cell.
- Y: Integer; The zero-based row index of the cell.
- IncValue: Int64; The integer value to add to the cell's current value.
RCell_Inc
Increments the numeric (`ThNumeric`) value of a specific cell, identified by its column and row index.
Procedure RCell_Inc(CONST X, Y: Integer; CONST IncValue: ThNumeric);
Parameters
- X: Integer; The zero-based column index of the cell.
- Y: Integer; The zero-based row index of the cell.
- IncValue: ThNumeric; The numeric value to add to the cell's current value.
Field_Inc
Appends text to the end of a string in a specified cell.If the cell already contains text, a separator is inserted before the new text is appended.
Procedure Field_Inc(CONST FldName: String; CONST Y: Integer; CONST Separation, Append_Text: String);
Parameters
- FldName: String; The name of the field (column) to modify.
- Y: Integer; The zero-based row index of the cell.
- Separation: String; The text to insert between the existing and new text if the cell is not empty.
- Append_Text: String; The text to append to the cell.
IField_Inc
Increments the integer value of a specific cell, identified by its field name and row index.
Procedure IField_Inc(CONST FldName: String; CONST Y: Integer; CONST IncValue: Int64);
Parameters
- FldName: String; The name of the field (column) to modify.
- Y: Integer; The zero-based row index of the cell.
- IncValue: Int64; The integer value to add to the cell's current value.
RField_Inc
Increments the numeric (`ThNumeric`) value of a specific cell, identified by its field name and row index.
Procedure RField_Inc(CONST FldName: String; CONST Y: Integer; CONST IncValue: ThNumeric);
Parameters
- FldName: String; The name of the field (column) to modify.
- Y: Integer; The zero-based row index of the cell.
- IncValue: ThNumeric; The numeric value to add to the cell's current value.
RField_Keep_Range
Ensures that the numeric value of a specific cell remains within a defined minimum and maximum range.If the cell's value is outside the bounds, it is adjusted to the nearest boundary.
Procedure RField_Keep_Range(CONST FldName: String; Y: Integer; CONST Minimum, Maximum: Double);
Parameters
- FldName: String; The name of the field (column) to check.
- Y: Integer; The row index of the cell. A negative value refers to the current row.
- Minimum: Double; The minimum allowed value for the cell.
- Maximum: Double; The maximum allowed value for the cell.
Push_Into_Fields
Adds a new value into the first available empty cell within a horizontal group of adjacent columns.This overloaded function can add either a `String` or a `Double`.
It first checks if the value already exists in the group to avoid duplicates.
Function Push_Into_Fields(CONST FldName: String; CONST GroupAmount: Byte; Y: Integer; CONST NewValue: Double): Boolean; Overload;
Function Push_Into_Fields(CONST FldName: String; CONST GroupAmount: Byte; Y: Integer; CONST NewValue: String): Boolean; Overload;
Parameters
- FldName: String; The name of the starting field (column) of the group.
- GroupAmount: Byte; The number of adjacent columns that make up the group.
- Y: Integer; The row index to operate on. A negative value refers to the current row.
- NewValue: Double or String; The new value to be pushed into an empty cell.
Return Value
Returns `True` if the value was successfully added or if it already existed in the group.Returns `False` if all cells in the group were already filled and the new value could not be added.
Get_Field_Name_Data
Creates a formatted string that combines a field's visual name (caption) with its value.This is a helper function typically used for generating display text or log entries.
Function Get_Field_Name_Data(CONST FldName: String; CONST Y: Integer; Bold: Boolean = False): String;
Parameters
- FldName: String; The name of the field to retrieve data from.
- Y: Integer; The row index of the cell.
- Bold: Boolean; If `True`, the value part of the string is wrapped in HTML bold tags (`...`). The default is `False`.
Return Value
Returns a formatted string, such as "Caption: Value".Returns an empty string if the specified cell has no value.
Refresh
Notifies all linked visual components, such as `ThDataGrid` or `ThFieldsArea`, that the table's data has changed and that they should repaint themselves to reflect the new state.
Procedure Refresh;
Selection
Returns a record that describes the currently selected range of rows.If only a single row is selected, the `FromRow` and `UntilRow` fields will be the same, and `HaveRange` will be `False`.
Function Selection: ThRowsRange;
Return Value
Returns a `ThRowsRange` record with the following fields:FromRow
: Integer; The starting row index of the selection.UntilRow
: Integer; The ending row index of the selection.HaveRange
: Boolean; `True` if more than one row is selected.
AllRows_OR_Selection
Acts as a convenience function to get a valid processing range.If the user has selected a multi-row range, this function returns that range.
If only a single row is selected, it returns a range encompassing all rows in the table.
Function AllRows_OR_Selection: ThRowsRange;
Return Value
Returns a `ThRowsRange` record representing either the user's current selection or the entire table.LoadFromAnsiFile
Loads data into the table from a text-based file, clearing any existing data first.It supports INI format and delimited formats like CSV (comma-separated) or TXT (tab-separated).
If no `FileName` is provided, an open file dialog will be shown to the user.
Function LoadFromAnsiFile(FileName: String = ''; Format: String = 'csv'; Delimited_Char: AnsiChar = #0): Boolean;
Parameters
- FileName: String; The full path to the file to load. If empty, a dialog is shown.
- Format: String; The format of the file, typically 'csv', 'txt', or 'ini'.
- Delimited_Char: AnsiChar; The character used as a delimiter. If left as #0, it defaults to a comma for 'csv' and a tab for 'txt'.
Return Value
Returns `True` if the file was loaded and parsed successfully, otherwise `False`.LoadCommaSeparated
Parses data from a memory stream containing delimited text (like CSV) and populates the table with it.This is the core parsing engine used by `LoadFromAnsiFile`.
It intelligently handles text qualifiers (double quotes) to correctly parse values that contain delimiters or line breaks.
Function LoadCommaSeparated(Source: ThMemoryStream; Delimited_Char: AnsiChar; Commas_As_Text_Block: Boolean = True): Boolean;
Parameters
- Source: ThMemoryStream; The stream containing the delimited text data.
- Delimited_Char: AnsiChar; The character used to separate values.
- Commas_As_Text_Block: Boolean; If `True` (default), it correctly handles values enclosed in double quotes, allowing them to contain commas and line breaks.
Return Value
Returns `True` if the data was parsed and loaded successfully.SaveToAnsiFile
Saves the table's data to a text file in one of several specified formats.
Function SaveToAnsiFile(FileName: String; Format: ThSaveToAnsiFile; Inc_Hidden_Flds: Boolean): Boolean;
Parameters
- FileName: String; The full path of the file to save.
- Format: ThSaveToAnsiFile; The desired output format.
- Inc_Hidden_Flds: Boolean; If `True`, hidden columns will be included in the output file.
ThSaveToAnsiFile
is an enumerated type that defines the various formats available when exporting a ThTable
to a text-based file using the SaveToAnsiFile
function.
Format | Description |
---|---|
he_Ansi_INI | Saves the data in an INI file format using the default system ANSI encoding. |
he_UTF8_INI | Saves the data in an INI file format using UTF-8 encoding. |
he_Ansi_CSV | Saves as a comma-separated values (CSV) file using ANSI encoding, without a header row. |
he_Ansi_CSV_With_Header | Saves as a comma-separated values (CSV) file using ANSI encoding, with a header row of column titles. |
he_UTF8_CSV | Saves as a comma-separated values (CSV) file using UTF-8 encoding, without a header row. |
he_UTF8_CSV_With_Header | Saves as a comma-separated values (CSV) file using UTF-8 encoding, with a header row of column titles. |
he_Ansi_TXT | Saves as a tab-delimited text file using ANSI encoding. |
he_CSV_For_SQL_Import | Creates a UTF-8 encoded, tilde-delimited (~) file with a header row, optimized for SQL database imports. |
he_CSV_Linux | Saves as a comma-separated values (CSV) file using UTF-8 encoding and Linux-style (LF) line endings. |
Return Value
Returns `True` if the file was saved successfully.Copy_To_Clipboard
Formats the table's data as a tab-delimited string and copies it to the system clipboard.This format is ideal for pasting directly into spreadsheet applications like Excel.
Function Copy_To_Clipboard(WithTitles: Boolean; FromRow: Integer = -1; UntilRow: Integer = -1): Boolean;
Parameters
- WithTitles: Boolean; If `True`, a header row with the column captions is included.
- FromRow: Integer; The starting row of the range to copy (default is -1 for the first row).
- UntilRow: Integer; The ending row of the range to copy (default is -1 for the last row).
Return Value
Returns `True` if the data was successfully copied to the clipboard.Save_To_String
Formats the table's data as a tab-delimited string, suitable for pasting into spreadsheets, and returns it.This function is similar to `Copy_To_Clipboard` but returns the result as a string instead of sending it to the clipboard.
Function Save_To_String(WithTitles: Boolean; FromRow: Integer = -1; UntilRow: Integer = -1): String;
Parameters
- WithTitles: Boolean; If `True`, a header row with the column captions is included.
- FromRow: Integer; The starting row of the range to format (default is -1 for the first row).
- UntilRow: Integer; The ending row of the range to format (default is -1 for the last row).
Return Value
Returns a `String` containing the tab-delimited data from the specified range.Paste_From_Clipboard
Parses tab-delimited text from the system clipboard or a provided string and pastes it into the table.It correctly handles multi-line data by creating new rows as needed and respects text qualifiers (double quotes), making it suitable for pasting data from spreadsheet applications.
Function Paste_From_Clipboard(InsertAt: Integer = -1; _ClipText: String = ''): ThRowsRange;
Parameters
- InsertAt: Integer; The row index where the pasting should begin. If -1 (default), new rows are added to the end of the table.
- _ClipText: String; An optional string containing the tab-delimited text. If this string is empty (default), the function will get the text from the system clipboard.
Return Value
Returns a `ThRowsRange` record indicating the range of new or modified rows that were created by the paste operation.LoadFromMemoryStream
Loads the table's entire dataset from a binary memory stream, overwriting any existing data.This procedure is used to deserialize a table that was previously saved with `SaveToMemoryStream`.
Procedure LoadFromMemoryStream(Source: ThMemoryStream);
Parameters
- Source: ThMemoryStream; The stream containing the binary table data.
SaveToMemoryStream
Saves the table's entire dataset into a new binary memory stream.This function is the counterpart to `LoadFromMemoryStream` and is used for serializing the table's state.
Function SaveToMemoryStream: ThMemoryStream;
Return Value
Returns a new `ThMemoryStream` object containing the complete binary representation of the table's data.LoadFromFile
Loads the table's dataset from a binary file, overwriting any existing data.It can handle both standard and encrypted data files.
Function LoadFromFile(FileName: String; Encrypted: Boolean = False): Boolean;
Parameters
- FileName: String; The full path of the binary file to load.
- Encrypted: Boolean; If `True`, the function will decrypt the file's content before loading it (default is `False`).
Return Value
Returns `True` if the file was loaded successfully, otherwise `False`.SaveToFile
Saves the table's entire dataset to a binary file on disk.This procedure is the counterpart to `LoadFromFile` and can optionally encrypt the output file.
Procedure SaveToFile(FileName: String; Encrypt: Boolean = False);
Parameters
- FileName: String; The full path of the file to save. If an empty string is provided, a save file dialog will be shown to the user.
- Encrypt: Boolean; If `True`, the file's content will be encrypted (default is `False`).
Save_HTML_To_MemoryStream
Converts the entire table's data into a standard HTML `Value | Description |
---|---|
he_Standard | Default mode. The table is fully editable and follows all schema rules. |
he_ReadOnly | The user cannot edit any data in the table. Hidden fields remain hidden. |
he_Fixing_Data_Interface | A special mode for developers or administrators to view and edit raw data, often bypassing certain UI rules. |
he_ReadOnly_No_Hidden | The table is read-only, but all hidden fields are made visible. |
he_Data_Interface | A mode typically used for data export or API-like access, where data is formatted in a raw, machine-readable way (e.g., dates as YYYY-MM-DD). |
Usage_Notes
A free-text string property intended for developers to store design-time notes or comments.It has no effect on the component's runtime behavior.
Property Usage_Notes: String;
Script_Events
A set property that enables or disables specific events for the framework's scripting engine.Only events included in this set will trigger a call to a corresponding script procedure.
Property Script_Events: ThScript_Events;
Values
The property is a set of values from the ThScript_EventsType
enumeration:
Event Type | Description |
---|---|
PS_Enabled | Globally enables or disables scripting for this component. |
PS_BeforeEdit | Triggers a script before a cell enters edit mode. |
PS_AfterEdit | Triggers a script after a cell's value has been modified. |
PS_AfterAdd | Triggers a script after a new row has been added. |
PS_AfterPaste | Triggers a script after data has been pasted into the table. |
PS_BeforeDelete | Triggers a script before a row is deleted. |
PS_AfterDelete | Triggers a script after a row has been deleted. |
PS_Replace | Triggers a script after a replace operation. |
Generate_Code_By_Cell
A boolean property used by design-time tools or wizards.When active, it likely alters the component's behavior to facilitate the automatic generation of Pascal source code for accessing cell data.
This property generally has no effect on the application's runtime behavior for end-users.
Property Generate_Code_By_Cell: Boolean;
Get_RealTime_Readonly
An event that is triggered to dynamically determine if a specific cell should be read-only.This allows for conditional read-only logic on a cell-by-cell basis, which overrides the static `ReadOnly` property of the field's schema.
Property Get_RealTime_Readonly: Tht_ConfimEventA;
Event Handler Signature
Tht_ConfimEventA = procedure(FieldName: String; DsRow: Cardinal; VAR Confirm: Boolean) of object;
- FieldName: The name of the field being checked.
- DsRow: The row index of the cell being checked.
- Confirm: Set this `VAR` parameter to `False` inside the event handler to make the cell read-only, or `True` to allow editing.
Before_Edit
An event that is fired just before a cell enters edit mode.It can be used to prepare data or perform actions prior to the user making changes.
Property Before_Edit: Tht_ExeCellEvent;
Event Handler Signature
Tht_ExeCellEvent = procedure(FieldName: String) of object;
- FieldName: The name of the field that is about to be edited.
After_Edit
An event that is fired immediately after a cell's value has been modified by the user.This is the primary event for validating new data, performing calculations, or triggering other business logic based on the change.
Property After_Edit: Tht_ExeCellEvent;
Before_Add
An event that is fired before a new row is added to the table.The event handler can prevent the row from being added.
Property Before_Add: Tht_ConfimEventC;
Event Handler Signature
Tht_ConfimEventC = procedure(VAR Confirm: Boolean) of object;
- Confirm: Set this `VAR` parameter to `False` inside the event handler to cancel the add operation. It is `True` by default.
After_Add
An event that is fired after a new row has been added and initialized with default values.This is the ideal place to populate the new row with calculated data or any required initial values.
Property After_Add: TThreadMethod;
Event Handler Signature
This event uses the standard TThreadMethod
type, which is a procedure that takes no parameters.
Before_Delete_Dlg
An event that is fired before the delete confirmation dialog is shown to the user.This event allows the developer to programmatically prevent the deletion from proceeding.
Property Before_Delete_Dlg: Tht_ConfimEventC;
Event Handler Signature
Tht_ConfimEventC = procedure(VAR Confirm: Boolean) of object;
- Confirm: VAR Boolean; A variable parameter that the event handler must set. Set it to
False
to cancel the delete operation and prevent the dialog from appearing. It isTrue
by default.
Before_Delete
An event that is fired after the user has confirmed the deletion but just before the row is actually removed from the table.This is the appropriate place for any cleanup logic that needs to be executed before the record's data is lost.
Property Before_Delete: TThreadMethod;
Event Handler Signature
This event uses the standard TThreadMethod
type, which is a procedure that takes no parameters.
After_Delete
An event that is fired immediately after a row has been successfully removed from the table.This is the appropriate place for logic that needs to run after the data is gone, such as updating UI elements or logging the deletion.
Property After_Delete: TThreadMethod;
Event Handler Signature
This event uses the standard TThreadMethod
type, which is a procedure that takes no parameters.
Before_Replace
An event that is fired before a `Replace` operation is executed on a column.The event handler can be used to validate the operation and prevent it from proceeding.
Property Before_Replace: Tht_ConfimEventB;
Event Handler Signature
Tht_ConfimEventB = procedure(FieldName: String; VAR Confirm: Boolean) of object;
- FieldName: String; The name of the field (column) on which the replace operation will occur.
- Confirm: VAR Boolean; A variable parameter that the event handler must set. Set it to
False
to cancel the replace operation. It isTrue
by default.
After_Replace
An event that is fired after a `Replace` operation has successfully completed on a column.
Property After_Replace: Tht_ExeCellEvent;
After_Paste
An event that is fired after data has been successfully pasted into the table from the clipboard.It provides the range of rows that were affected by the paste operation.
Property After_Paste: Tht_PasteEvent;
Event Handler Signature
Tht_PasteEvent = procedure(FromRow, UntilRow: Cardinal) of object;
- FromRow: Cardinal; The starting row index of the pasted data.
- UntilRow: Cardinal; The ending row index of the pasted data.
PopList_Event
An event that is triggered when the user activates a field with an `EditorType` of `he_PopupList`.This event is typically used to dynamically populate or display a custom popup or dialog for the specified field.
Property PopList_Event: Tht_ExeCellEvent Read FPopList_Event Write FPopList_Event;
Event Handler Signature
procedure(FieldName: String) of object;
- FieldName: String; The name of the field that triggered the event.
ON_Cell_Modified
A low-level event that is fired whenever a cell's value is changed programmatically.It provides both the old and new values as strings, making it useful for change tracking, auditing, or logging.
Property ON_Cell_Modified: Tht_CellModified Read FOn_Cell_Modified Write Set_On_Cell_Modified;
Event Handler Signature
procedure(Col, Row: Cardinal; OlderValueStr, NewValueStr: String) of object;
- Col: Cardinal; The column index of the cell that was modified.
- Row: Cardinal; The row index of the cell that was modified.
- OlderValueStr: String; The value of the cell before the modification.
- NewValueStr: String; The new value of the cell after the modification.
OnCompare_Rows
An event used by the `Find_And_Handle_Rows_Group_By_Events` procedure.It is called for each pair of adjacent rows in the table, and the event handler must determine if they belong to the same logical group.
Property OnCompare_Rows: Tht_CompareEvent;
Event Handler Signature
Tht_CompareEvent = procedure(Row1, Row2: Cardinal; VAR SameGroup: Boolean) of object;
- Row1: Cardinal; The index of the first row in the comparison.
- Row2: Cardinal; The index of the second row in the comparison.
- SameGroup: VAR Boolean; The event handler must set this parameter to `True` if the two rows belong to the same group, and `False` otherwise.
OnHandle_Rows_Group
An event used by the `Find_And_Handle_Rows_Group_By_Events` procedure.After a complete group of rows has been identified using the `OnCompare_Rows` event, this event is fired once to allow for batch processing of that entire group.
Property OnHandle_Rows_Group: Tht_PasteEvent;