OnActivate2 (C++)
Description
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 list box and then activate Form2 by clicking in it. Also, set the visible property of Form2 to True.
Code
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]);
};
}
Uses
- Vcl.Forms.TCustomForm.OnActivate ( fr | de | ja )
- System.Classes.TComponent.ComponentCount ( fr | de | ja )
- System.Classes.TComponent.Components ( fr | de | ja )