OnActivate2 (Delphi)
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 you 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.
Code
procedure TForm2.FormActivate(Sender: TObject);
begin
if (Form1Done) then
begin
DBGrid2.DataSource :=
Form1.ListBox1.Items.Objects[Form1.ListBox1.ItemIndex] as TDataSource;
DBNavigator2.DataSource :=
Form1.ListBox1.Items.Objects[Form1.ListBox1.ItemIndex] as TDataSource;
end;
end;
Uses
- Vcl.Forms.TCustomForm.OnActivate ( fr | de | ja )
- System.Classes.TComponent.ComponentCount ( fr | de | ja )
- System.Classes.TComponent.Components ( fr | de | ja )