>Can I change table in DBGrid dynamically?
Here is an extract of a program where I allow the user to pick the way items
are listed in a grid. Itkwma is a table that contains keywords referenced
to a stock number and Itemma is the stock number file.
unit Itemsrch;
. . .
TFormItemsrch = class(TForm)
GridItems: TDBGrid;
Itkwma: TTable;
SourceItkwma: TDataSource;
Itemma: TTable;
SourceItemma: TDataSource;
RadioSelect: TRadioGroup;
procedure RadioSelectClick(Sender: TObject);
procedure GridItemsDblClick(Sender: TObject);
end;
var
FormItemsrch: TFormItemsrch;
implementation
{$R *.DFM}
uses
ItemEdit;
procedure TFormItemsrch.RadioSelectClick(Sender: TObject);
begin
{Select the datasource and form caption based on the user's radio
button selection}
case RadioSelect.ItemIndex of
0: begin
GridItems.DataSource := SourceItkwma;
Caption := 'Find Items by keyword';
end;
1: begin
Itemma.IndexName := '';
GridItems.DataSource := SourceItemma;
Caption := 'Find Items by stock number';
end;
2: begin
Itemma.IndexName := 'Vensty';
GridItems.DataSource := SourceItemma;
Caption := 'Find Items by vendor/style';
end;
end;
end;
procedure TFormItemsrch.GridItemsDblClick(Sender: TObject);
begin
{If the user double-clicks in the grid, identify the item and start the
edit screen (in unit Itemedit)}
if not (GridItems.DataSource.Dataset.BOF
and GridItems.DataSource.Dataset.EOF) then begin
ItemSelected :=
GridItems.DataSource.Dataset.FieldByName('StockNo').AsFloat;
DoItemEdit(ItemSelected);
end;
end;
------------------------------------------------
Kirk B. Spadt ksp...@keyware.com
Keyware Systems, Inc.
570 Lindsey Drive (610) 964-9530
Radnor, PA 19087 (610) 964-0543 fax
Yes
>Can I change table in DBGrid dynamically?
Here is an extract of a program where I allow the user to pick the way items