unit DemoFrm;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,
DB, ABSMain, Grids, DBGrids, ComCtrls;
type
TDemoForm =
class(TForm)
TreeView: TTreeView;
DBGrid: TDBGrid;
ABSDatabase: TABSDatabase;
ABSTable: TABSTable;
DataSource: TDataSource;
procedure TreeViewChange(Sender: TObject; Node: TTreeNode);
procedure DBGridTitleClick(Column: TColumn);
private
procedure SwitchTable(
const tblName:
string);
procedure SwitchIndex(
const idxName:
string);
end;
var
DemoForm: TDemoForm;
implementation
{$R *.dfm}
uses
StrUtils;
procedure TDemoForm.SwitchIndex(
const idxName:
string);
begin
with AbsTable
do
if not SameText(idxName, IndexFieldNames)
then
begin
DisableControls;
try
IndexFieldNames := idxName;
finally
EnableControls;
end;
end;
end;
procedure TDemoForm.SwitchTable(
const tblName:
string);
begin
with AbsTable
do
if not SameText(tblName, TableName)
then
begin
DisableControls;
try
if Active
then Close;
SwitchIndex('
');
TableName := tblName;
if TableName <> '
'
then Open;
finally
EnableControls;
end;
end;
end;
procedure TDemoForm.TreeViewChange(Sender: TObject; Node: TTreeNode);
begin
SwitchTable(IfThen(Assigned(Node), Node.Text));
end;
procedure TDemoForm.DBGridTitleClick(Column: TColumn);
begin
SwitchIndex(Column.FieldName);
end;
end.