Delphi & C++ Builder components library
and Software development
 
 
 

DB Dialogs and Actions - how to use it

Step 0 - preparing application

  • Create new application with any type of connection to database (dbGo, dbExpress, IB, FireDac...)
  • Place TDataSet, TDataSource and rDBGrid to form and connect all together to show data in rDBGrid
  • Add columns to TDataSet and to rDBGrid (via Columns property or via design time editor)
Or download prepared demo application.

Variant A - using DB Dialogs without rDBActions

  • add reference to uses part of form: uses rstring, rdlg, rtool, rdbtool, rDBFind, rDBFilter, rDBFields, rDBExport, rDBGridProps, rDBFilterSaver, rDBPrint, rDBPrintDirect, rDBSort2, rDBGridCellParams;
  • Find dialog - call rDBFind.FindRec(rDBGrid1);
  • Filter dialog - call rDBFilter.FilterRec(rDBGrid1);
  • Filter by selection - call rDBFilter.FilterBySel(rDBGrid1); and so on for another filter function (see rDBFilter.pas and rDBFilterSaver.pas for detail)
  • Fields dialog - call rDBFields.ChooseFields(rDBGrid1);
  • Grid properties dialog - call rDBGridProps.DBGridProperties(rDBGrid1,true);
  • Export dialog - call rDBExport.DBExport(rDBGrid1,true,true);
  • Print to RTF dialog - call rDBPrint.DBPrint(rDBGrid1,true,true,'Caption')
  • Print direct dialog - call rDBPrintDirect.DBPrintDirect(rDBGrid1,true,true,'Caption')
Parameters of most dialogs procedures can be DBGrid, rDBGrid or TDataSet.

Variant B - using rDBAction

Preparing application for using rDBAction
  • Use Add file to project and add unit dm_rDBAction.pas from RosiFormShared directory
  • Use Add file to project and add unit dm_rImages.pas from RosiFormShared directory
  • Use Add file to project and add unit fr_DBToolbar.pas from RosiFormShared directory
  • Use Add file to project and add unit fr_DBEditbar.pas from RosiFormShared directory
  • Open Project-Options dialog and move dm_rImages + dm_rDBAction form to first position on Auto-create forms (MUST!)
Using rDBAction toolbars and menus in form
  • Add reference to rDBAction to uses part of form.
  • Open OnShow (or OnActivate if you using non modal forms) event of form and add code rDBAction.SetActiveGrid(rDBGrid1);
  • Find PopupMenu property of rDBGrid1 and select value rDBAction.pmDBAction
  • Place new Frame to form and select rDBToolBar
  • Place new Frame to form and select rDBEditBar
  • Open design time editor of rDBGrid (dblclick on it) and in tab rDBAction select which action should be available for this grid
  • Run the application
Use the same steps for each form in application with DBGrid or create one universal form and create descendant for each new form. Using more grids in one form (e.g. with TTabControl) - use only one rDBToolBar and rDBEditBar and call rDBAction.SetActiveGrid(ActiveGrid) after changing of Tab (ActiveGrid is actually selected grid).

Sorting


Sorting action depends on the used dataset component and can be implemented in two ways:
  • install package rDBGridSorters.dpk which contains rDBGridSorter components for standard datasets (ADO, DBX, ClientDataset, FireDac, Zeos), use rDBGridSorter component according used dataset type and link rDBGrid.Sorter property to rDBGridSorter component, sorting is provided automatically
  • OR
  • find OnChangeSortEx event of rDBGrid and add code to sort dataset according parameters SortFieldNames,SortDirections, Accept value is used to inform DBGrid that sorting was set and sort markers can be shown

For dbGo (ADO) solution is prepared in unit rdbtool_ADO, just call rdbtool_ADO.ChangeSortExADO(DataSet as TCustomADODataSet,SortFieldNames,SortDirections,Accept)

Using rDBAction with another buttons

In some cases is better to use TButton or TToolButton instead of predefined toolbars. Implementation is very easy:
  • Add reference to rDBAction to uses part of form.
  • Open OnShow (or OnActivate if you using non modal forms) event of form and add code rDBAction.SetActiveGrid(rDBGrid1);
  • Place new Button or ToolButton to form
  • Find Action property of this Button and select any action of listed rDBActions
  • Run the application
or use TDBMoveButton with direct link to any datasource instead of rDBActions

Global configuration of DB Dialogs and Actions

File RosiCompGlobalCfg.pas contains global configuration used by all DB Dialogs. Update any value by application to modify standard look or behaviour.

Open documentation page.

Go back