Subject Re: [IBO] Datasource state aware button
Author Marc Leclerc
Hi,

My Datasource is in the main datamodule and of course I could set a handler
there and add chek to see if the main form is created and deal with it
there, but I don't beleive this code belongs there since I have four
TabSheet displaying four detail tables and four button
(edit,add,delete,display) whose state depend on the dataset showed in the
current sheet of the main form. From the datamodule I can manage state for
other purpose with the datasource events and keep the code that manage the
mainform within it hooking to the datasource.

So in my main form I have the following (remember the mainform diaplay is
read-only)

procedure TfrmCDSMain.IB_DataSourceEvents1DataChange(Sender: TIB_DataLink;
ADataSource: TIB_DataSource; AField: TIB_Column);
begin
inherited;
if ( AField = nil ) then { browsing (should always be true in my case)}
begin
SetLinkedButtonState(ADataSource);
end;
end;

procedure TfrmCDSMain.FormShow(Sender: TObject);
begin
inherited;
SetLinkedButtonState(DM.IB_DSRequest);
SetLinkedButtonHints(DM.IB_DSRequest);
end;

procedure TfrmCDSMain.PageControlLinksChange(Sender: TObject);
begin
inherited;
with PageControlLinks do
case ActivePage.Tag of
1 : IB_DataSourceEvents1.DataSource := DM.IB_DSRequest;
2 : IB_DataSourceEvents1.DataSource := nil;
3 : IB_DataSourceEvents1.DataSource := DM.IB_DSTask;
4 : IB_DataSourceEvents1.DataSource := nil;
end;
SetLinkedButtonState(IB_DataSourceEvents1.DataSource);
SetLinkedButtonHints(IB_DataSourceEvents1.DataSource);
end;

Instead of something in the DM like

OnDataChange
Begin
If Assign(frmCDSMain) then
with frmCDSMain do begin
case PageControl1.ActivePage.Tag of
...
end;
...
end;
End;


And more stuff in the mainform (on pagechange, On Show...)


----- Original Message -----
From: "Nando Dessena" <nandod@...>
To: <IBObjects@yahoogroups.com>
Sent: Thursday, March 08, 2001 3:59 AM
Subject: Re: [IBO] Datasource state aware button


> Marc,
>
> > So I ported and old componend I have made which simply hooks to a
> > Datasource and publish some of the datasource event so I can react
> > within the main form to state changes.
>
> isn't that what a DataSource itself is for? What is the added value of
> your component?
> Just curious.
> --
> ____
> _/\/ando
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>