Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can I change table in DBGrid dynamically?

6 views
Skip to first unread message

Pavel

unread,
Jun 4, 1997, 3:00:00 AM6/4/97
to

Can I change table in DBGrid dynamically?

Kirk B. Spadt

unread,
Jun 6, 1997, 3:00:00 AM6/6/97
to

In article <33958D...@topaz.kiev.ua>, Pavel <pa...@topaz.kiev.ua> wrote:
>Path:

>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

Andrew Gabb

unread,
Jun 6, 1997, 3:00:00 AM6/6/97
to

Pavel wrote:
>
> Can I change table in DBGrid dynamically?

Yes


Kirk B. Spadt

unread,
Jun 8, 1997, 3:00:00 AM6/8/97
to

In article <33958D...@topaz.kiev.ua>, Pavel <pa...@topaz.kiev.ua> wrote:
>Path:

>Can I change table in DBGrid dynamically?

Here is an extract of a program where I allow the user to pick the way items

0 new messages