Copyright: © 2000, Olga Vlasova


Overview

Volga Components Library contains following visible components:

TVolgaDBGrid - improved DBGrid control, fully replaces standart TDBGrid

TVolgaDBEdit - improved DBEdit/DBComboBox/DBLookup/DBDatePicker control

TVolgaCalendar - Calendar control, is also used in TVolgaDBGrid and TVolgaDBEdit

TVolgaPeriod - component for change periods (ranges) of date

TVolgaFindEdit - component for incremental search or filter in dataset

All these components are freeware with full source code.

Copyright © 2000 Vlasova Olga, Russian Federation

URL: http://volgatable.chat.ru

E-mail: volgatable@chat.ru


Install notes

To install components from VolgaPak:

•	Place all *.pas, *.dfm, *.dcr, *.res, *.dpk files in one folder.

•	Open VolgaPD4.dpk (VolgaPD5.dpk for Delphi5) in Delphi IDE.

•	Click on button Compile, then on button Install.

•	Add path to folder with package into Environment, Library path.

Unit VolDBConsts.pas contains resource strings for multilanguage support.


TVolgaCalendar

TVolgaCalendar - component for date choice from calendar. It contains full calendar for one month with buttons for change date.You may change current month, current year, select month directly from dropdown list of months (by clicking on month name), select today date (by clicking on today panel) or select date from calendar. TVolgaCalendar is used as dropdown control in TVolgaDBGrid and TVolgaDBEdit.

Properties, events and methods:

public

   property Selected:Boolean read FSelected;

//it is true after user select new date

published

   property Day:word read FDay write SetDay;

//day of currently selected date

   property Month:word read FMonth write SetMonth;

//month of currently selected date

   property Year:word read FYear write SetYear;

//year of currently selected date

   property Date:TDateTime read FDate write SetDate;

//currently selected date

   property Text:string read GetText write SetText;

//date as string

   property OnSelectDate: TNotifyEvent read FSelectDate write FSelectDate;

//event after user select new date

   property OnChangeDate: TNotifyEvent read FChangeDate write FChangeDate;

//event after current date changed


TVolgaDBGrid

TVolgaDBGrid is improved DBGrid. It fully replace standart TDBGrid, so you don't need to include standart unit DBGrids. Column button style of TVolgaDBGrid may be:

•	cbsCombo - dropdown list of predefined text items from property PickList, with corresponding values in PickValues;

•	cbsLookup - dropdown list from lookup table; you don't need to create new calculated or lookup field in viewing table, this style may be used for code field to show correspond text values from lookup table;

•	cbsCalendar - dropdown calendar for date field, used TVolgaCalendar;

•	cbsCheck - check box in grid cell;

•	cbsEllipsis - custom dialog is called;

•	cbsNone - simple edit cell.

Title cells in TVolgaDBGrid may be buttons, if CanClick property of Column is set to true. Long text in cell is show as hint then cell is clicked (if LongTextAsHint property is true). You can change attributes (font, color) of any data cell or title cell in OnDrawCellAttr and OnDrawTitleAttr event handlers. Calculated fields may be edited in grid, if you write OnCalcFieldEdited event handler. You can change the behavior of dropdown controls or lookup table in BeforeDropDown and AfterCloseUp event handlers.

Properties, events and methods:

in TVolgaColumn:

procedure AssignList(const AList: TStrings);

//assign string list (like Name=Value) to PickList and PickValues at the same time

 property AutoDropDown: Boolean read FAutoDrop write FAutoDrop default false;

//dropdown control is dropped then user begin to edit cell

property ButtonStyle: TVolgaColumnButtonStyle read FButtonStyle write SetButtonStyle

  default cbsNone;

//kind of dropdown control

  property CanClick: Boolean read FCanClick write FCanClick default false;

//title cell can clicked as button

  property DropDownRows: Cardinal read FDropDownRows write FDropDownRows default 10;

//count of dropdown items

  property DropDownWidth: Cardinal read FDropDownWidth write FDropDownWidth default 0;

//width of dropdown list, if 0 then is equal to cell width, for dropdown lists only.

  property LongTextAsHint: Boolean read FTextAsHint write FTextAsHint default false;

//on cell selected long text on cell is shown as hint

  property LookupDropDownFields: string read FLookupDropDownFields write SetLookupDropDownFields;

//list of fields from lookup table in dropdown lookup control (separated with ;)

  property LookupKeyField: string read FLookupKeyField write SetLookupKeyField;

//one field from lookup table to link

  property LookupLinkField: string read FLookupLinkField write SetLookupLinkField;

//one field from source table to link

  property LookupDataSet: TDataSet read FLookupDataSet write SetLookupDataSet;

//lookup table

  property PickList: TStrings read GetPickList write SetPickList;

//text items in combo dropdown list

  property PickValues: TStrings read GetPickValues write SetPickValues;

//correspond values for text items, if they are exist and PickValues.Count = PickList.Count then Combo dropdown control behaves as Lookup control.

  property ValueChecked: string read FValueChecked write SetValueChecked;

//for check button style only

  property ValueUnChecked: string read FValueUnChecked write SetValueUnChecked;

//for check button style only

in TVolgaDBGrid:

function ColumnByName(const AName: string): TVolgaColumn;

//returns column by it's FieldName

 property OnDrawTitleAttr: TDrawTitleAttrEvent;

//you can change font properties and bacjground color of title cell

 property OnDrawCellAttr: TDrawCellAttrEvent;

//you can change font properties and bacjground color of data cell

 property OnEditButtonClick: TVolgaDBGridClickEvent;

//call custom dialog for edit field in cell

 property OnCalcFieldEdited: TCalcFieldEditedEvent;

//if this event handler <>nil, calculated fields may be edited in grid, and in this event handler you may do some processing;

 property OnTitleClick: TVolgaDBGridClickEvent;

//to do something then title is clicked

   property BeforeDropDown: TVolgaDBGridClickEvent;

//before DropDown control is dropped in column (example - for setting range)

 property AfterCloseUp: TVolgaDBGridCloseUpEvent;

//after dropdown list is closed

property OnSpecialKeyDown: TVolgaSpecialKeyDownEvent;

//to do something then user pressed any special key in Inplace Editor (then editing text in cell) (such key as F1-F12, BackSpace, Delete, Insert etc.)

TCalcFieldEditedEvent = procedure(Sender: TObject; Field: TField;     Text: string) of object;

TDrawDataCellEvent = procedure(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState) of object;

TDrawTitleAttrEvent = procedure(Sender: TObject; Column: TVolgaColumn; AFont: TFont; var AColor: TColor) of object;

TDrawCellAttrEvent = procedure(Sender: TObject; Column: TVolgaColumn; AFont: TFont; var AColor: TColor; State: TGridDrawState) of object;

TVolgaDBGridClickEvent = procedure(Sender: TObject; Column: TVolgaColumn) of object;

TVolgaDBGridCloseUpEvent = procedure(Sender: TObject; Column: TVolgaColumn; Selected: Boolean) of object;

TVolgaSpecialKeyDownEvent = procedure(Sender: TObject; Column: TVolgaColumn; var Key: Word; AText: string) of object;


TVolgaDBEdit

TVolgaDBEdit replaces TDBEdit, TDBComboBox, TDBLookupCombo, TDBLookupTree, TDBDatePicker etc. in one component. TVolgaDBEdit may be DB-aware and non DB-aware, if you don't set properties DataField and DataSource.

It has following dialog styles:

•	vdsEdit - simple edit box;

•	vdsCustomDlg - simple edit box with [...] button for custom dialog call;

•	vdsCombo - dropdown list with predefined Items and corresponding Values;

•	vdsLookup - dropdown list with lookup Items from lookuptable;

•	vdsCalendar - dropdown calendar for date editing;

•	vdsTree - dropdown treeview filled from lookup table.

TVolgaDBEdit supports ENTER and Up/Down keys for navigating between several TVolgaDBEdit components and Space key to drop dropdown list, if style is AutoDropDown. It supports also BackSpace or Delete key for delete it's Text and set it's value to ClearValue property.

Properties, events and methods:

TVolgaDBEdit = class(TCustomMaskEdit)

public

    procedure CreateDropDownList;

//create or update dropdown list after changing it's properties (calls automatically)

    function IsLinkActive:Boolean;

//is link (lookup) source dataset active

   property ItemIndex: integer read GetItemIndex write SetItemIndex;

//for combos,lookups and trees you can set index of selected record (for non DB-aware control) or read ItemIndex of selected item

    property Value: Variant read FValue write SetValue;

//present value of control (DataField value if it is DB-aware), differ from Text, if it is lookup or combo with values or treeview

published

  property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;

//used for vdsEdit dialog style

    property AutoDropDown: Boolean read FAutoDrop write FAutoDrop default false;

//dropdown list will dropped automatically, if any key is pressed

    property ClearValue: string read FClearValue write FClearValue;

//fill value for empty Text property

    property ComboProps: TVolgaComboProperties read GetComboProps write SetComboProps;

//set of properties for combo dialog style(ComboItems, ComboValues)

    property DataField: string read GetDataField write SetDataField;

//set DataField for DB-aware style component

    property DataSource: TDataSource read GetDataSource write SetDataSource;

//set DataSource for DB-aware style component

    property DropDownRows: Cardinal read FDropDownRows write FDropDownRows default 10;

//max amount of dropped lines for combo, lookup,tree dialog styles

    property DropDownWidth: Cardinal read FDropDownWidth write FDropDownWidth default 0;

//width of dropdown list, if 0 then is equal to width of control

    property DialogStyle: TVolgaDialogStyle read FDialogStyle write SetDialogStyle default vdsEdit;

//style of dialog - vdsEdit, vdsCombo, vdsLookup, vdsCalendar, vdsTree, vdsCustomDlg

    property LookupDataset: TDataSet read FLookupDataset write SetLookupDataset;

//lookup DataSet for lookup and treeview dialog style

    property LookupProps: TVolgaLookupProperties read GetLookupProps write SetLookupProps;

//set of properties for lookup dialog style(LookupKeyField, SourceKeyField, ListFieldNames, ViewFieldIndex)

    property Style: TVolgaComboBoxStyle read FStyle write FStyle default vcsDropDown;

//dropdown style (DropDown or DropDownList)

    property TreeProps: TVolgaTreeProperties read GetTreeProps write SetTreeProps;

//set of properties for lookup tree dialog style(PathSeparator, LevelField, TextField, UniqueField)

    property OnCloseUp: TCloseUpEvent read FOnCloseUp write FOnCloseUp;

//event after dropdown list is closed

    property OnCustomDlg: TNotifyEvent read FOnCustomDlg write FOnCustomDlg;

//occurs then user click custom dialog button

    property OnDisplayText: TGetTextEvent read FOnDisplayText write FOnDisplayText;

//event for custom filling text in control

    property OnUpdateData: TSetTextEvent read FOnUpdateData write FOnUpdateData;

//occurs after data is updated

Lookup tree dataset must be sorted on tree index order, must have integer level field, text field and unique field. For example: structure of lookup tree table: IndexID, Name, UniqueID, LevelNum, order by IndexID.

TVolgaDBEdit uses component TVolgaCalendar for dropdown date editing.

TVolgaComboProperties = class(TPersistent)

//properties for vdsCombo style control

public

  procedure AssignList(const AList: TStrings);

//assign ComboItems and ComboValues simultaneously from TStrings with lines like "Name=Value"

  property HasValues: Boolean read GetHasValues;

//is true then ComboValues<>nil and ComboValues.Count=ConmboItems.Count

published

  property ComboItems: TStrings read GetComboItems write SetComboItems;

//text items in combobox

  property ComboValues: TStrings read GetComboValues write SetComboValues;

//corresponding values for text items, may be absent

TVolgaLookupProperties = class(TPersistent)

//properties for vdsLookup style control

public

  property ViewField: string read GetViewField;

//one visible field in edit box from many visible fields in dropdown list

published

  property SourceKeyField: string read FSourceKeyField write SetSourceKeyField;

//field from source table for link to lookup table, may be equal to DataField

  property LookupKeyField: string read FLookupKeyField write SetLookupKeyField;

//key field from lookup table for search text value

  property ListFieldNames: string read FListFieldNames write SetListFieldNames;

//list of fields from lookup table, which will be in dropdown list

  property ViewFieldIndex: Integer read FListFieldIndex write FListFieldIndex default 0;

//number of field from ListFieldNames, which will be shown in control then dropdown list is closed

TVolgaTreeProperties = class(TPersistent)

//properties for vdsTree style control

public

  procedure PrepareTree;

//called internal for prepare tree nodes from table records

published

  property LevelField: string read FLevelField write FLevelField;

//name of field from lookup table, where level of node is stored

  property PathSeparator: char read FSeparator write FSeparator default '/';

//separator symbol for full path text from parent to child node

  property TextField: string read FTextField write FTextField;

//name of field from lookup table, where text of tree node is stored

  property UniqueField: string read FUniqueField write FUniqueField;

//name of field from lookup table, where unique ID for node is stored


TVolgaPeriod

TVolgaPeriod is component for change period (range) of date. It can turns over months, quarters, half years and whole years. Start and end date of current range are saved in properties. Kind of turned range may be changed at run time from popup menu.

Properties, events and methods:

  public

    property StartDate: TDateTime read FStartDate write SetStartDate;

//start date of current period

    property EndDate: TDateTime read FEndDate;

//end date of current period

    property Text: string read GetText;

//current period in text format

  published

    property KindRange: TKindRange read FKindRange write SetKindRange;

//kind of range: ksMonth, ksQuarter, ksHalfYear, ksYear

    property Year: word read FYear write SetYear;

//year of current period

    property Month: word read FMonth write SetMonth;

//first month of current period

    property OnChange: TNotifyEvent read FOnChange write FOnChange;

//after period is changed (manually or in code)

    property ButtonWidth: byte read FButtonWidth write SetButtonWidth;

//width of UpDown button

    property EnablePopup: Boolean read FEnablePopup write SetEnablePopup;

//enabled auto popup menu for changing kind of range

    property BeforeChange: TNotifyEvent read FBeforeChange write FBeforeChange;

//before period is changed (manually or in code)


TVolgaFindEdit

TVolgaFindEdit is TCustomEdit descendand for searching through dataset. It can search incrementally from start position of the field or organize context filtering. If you enter text in edit box, linked dataset is scrolled or filtered. If edit box is empty, filtering is disabled.

Properties and methods:

public

  procedure Find(AText: string);

//search in code (as opposed to enter text in edit box by keyboard)

published

property DataField: string read GetDataField write SetDataField;

//Field name for searching in it

property DataSource: TDataSource read GetDataSource write SetDataSource;

//Link to dataset

property FindStyle: TVolgaFindStyle read FFindStyle write SetFindStyle default vfsNavigate;

//Style of finding: vfsNavigate or vfsFilter

property FindMode: TVolgaFindMode read FFindMode write SetFindMode default vfmFirstPos;

//Find text at start position or in any position (vfmFirstPos, vfmAnyPos), for vfsNavigate style may be only vfmFirstPos

property IgnoreCase: Boolean read FIgnoreCase write SetIgnoreCase default true;

//Ignore case when searching or no.