//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
#include "OnActivate.h"
USEFORM("OnActivate.cpp", Form1Done);
USEFORM("OnActivate.cpp", Form1);
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm2 *Form2;
//---------------------------------------------------------------------------
__fastcall TForm2::TForm2(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: OnActivate2
// Event: Forms.TCustomForm.OnActivate
// Property: Classes.TComponent.ComponentCount
// Property: Classes.TComponent.Components

// BeginCode
/*
The following code sets the DataSource for a DBGrid
component in Form2 to the currently selected data source in
a list provided in Form1. This allows users to specify the
desired information in Form1, and then move to Form2 to view
the information. Select an item in the listbox and then
activate Form2 by clicking in it. Also, set the visible property
of Form2 to true.
*/
void __fastcall TForm2::FormActivate(TObject *Sender)
{
  if (Form1Done)
  {
	DBGrid2->DataSource =
	  dynamic_cast<TDataSource *>(Form1->ListBox1->Items->Objects[Form1->ListBox1->ItemIndex]);
	DBNavigator2->DataSource =
	  dynamic_cast<TDataSource *>(Form1->ListBox1->Items->Objects[Form1->ListBox1->ItemIndex]);
  };
}
// EndCode
// EndExample: OnActivate2
//---------------------------------------------------------------------------

