EhLib
ContentsIndexHome
PreviousUpNext
Common understanding of edit controls

EhLib has a set of data-aware edit controls to edit data: TDBEditEh, TDBDateTimeEditEh, TDBComboBoxEh, TDBNumberEditEh and TDBLookupComboboxEh. EhLib doesn’t have not data-aware version of these controls because every control can work as in data-aware mode and not in data-aware mode. The base class for every edit control is TCustomDBEditEh. TCustomDBEditEh encapsulates the behavior that is common for all edit controls for editing text and if it is required for editing a DataSet’s field by introducing methods and properties that provide:

  • Basic text editing functions such as selecting text, modifying selected text, and case conversions.
  • Properties for making it read-only or introducing a password character to hide the actual value.
  • Validity checking using an edit mask.
  • Writing edited text to database field.
  • Showing one or several edit buttons (with variable glyphs: dropdown arrow, Ellipsis arrow, up-down arrows, plus sign, minus sign or custom bitmap) at right part of edit box,
  • Showing image from image list at the left part of the edit box.

 

Application can use Text (String type) and Value (Variant type) properties to get and set string or variant values to controls. Text property is a text that you can see in control. Value property hold value of variant type and can hold values of types depending of control type. It can hold Null value or:

  • String type value for TDBEditEh and TDBComboBoxEh;
  • TDateTime, TDate, TTime, Double type value for TDBDateTimeEditEh;
  • All numeric types value for TDBNumberEditEh;
  • TDBLookupComboboxEh control hold value that depends on type of the field.

 

If control is connected to the field then the assignment data to the Text or Value properties automatically write data to the field. 

Every control has Flat and AlwaysShowBorder properties to control the border appearance.

All controls have EmptyDataInfo property that allows customize edit control to draw special text and font when control have no data (Edit1.Text = ‘’).

Dynamics properties in components - DynProps.

DynVarsEh is declared in a module class TDynVarsEh which implements a dynamic collection of scalar variables. Property of the type declared in the component can store a collection of named dynamic set of variables. 

Property type TDynVarsEh is declared with the following components and classes:

  • TDBGridEh.DynProps
  • TColumnEh.DynProps
  • TDBEditEh.DynProps
  • TDBDateTimeEditEh.DynProps
  • TDBComboBoxEh.DynProps
  • TDBNumberEditEh.DynProps
  • TDBCheckBoxEh.DynProps

Collection TDynVarsEh generated from class TCollection. In Design-Time can create the elements of the type TDynVarEh with the following properties:

public
    property AsBoolean: Boolean;
    property AsCurrency: Currency;
    property AsDateTime: TDateTime;
    property AsFloat: Double;
    property AsInteger: LongInt;
    property AsRefObject: TObject;
    property AsString: String;
    property IsNull: Boolean;
published
    property Name: String;
    property Value: Variant;

In Run-Time collection items can be created dynamically by assigning values. 

When reading a collection of values (DBEditEh1.DynProps ['Var1'].Value), if the item in the collection named 'Var1' is present in the list, it returns the value of the variable. If the element name is not present, it returns the value Unassigned. 

When assigning values, the algorithm checks for the item in the collection. 

DBEditEh1.DynProps ['Var1'].Value: = 'StrValue1'

If the item named 'Var1' isn’t in the list, a new element is created in the collection and is assigned with the specified value.

Working with edit buttons.

Every edit control allows to have one or more edit buttons on the right side. You can use EditButton and EditButtons to control them.

Copyright (c) 1998-2013. All rights reserved.
What do you think about this topic? Send feedback!