home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Delphi.5 / Samples / sourceD5 / browutil.exe / BROWSER / MASTLINK.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  2000-01-03  |  2.4 KB  |  86 lines

  1. unit MastLink;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, ExtCtrls, Db, DBTables;
  8.  
  9. type
  10.   TFrmMasterLink = class(TForm)
  11.     Panel1: TPanel;
  12.     Panel2: TPanel;
  13.     Label1: TLabel;
  14.     ComboBox1: TComboBox;
  15.     BtnOk: TButton;
  16.     BtnClose: TButton;
  17.     Label2: TLabel;
  18.     Label3: TLabel;
  19.     ListBox1: TListBox;
  20.     ListBox2: TListBox;
  21.     BtnAdd: TButton;
  22.     ListBox3: TListBox;
  23.     BtnClear: TButton;
  24.     BtnDelete: TButton;
  25.     Label4: TLabel;
  26.     ComboBox2: TComboBox;
  27.     Label5: TLabel;
  28.     Label6: TLabel;
  29.     ComboBox3: TComboBox;
  30.     ComboBox4: TComboBox;
  31.     procedure FormCreate(Sender: TObject);
  32.     procedure ComboBox2Change(Sender: TObject);
  33.     procedure ComboBox4Change(Sender: TObject);
  34.   private
  35.     { Private declarations }
  36.   public
  37.     { Public declarations }
  38.   end;
  39.  
  40. var
  41.   FrmMasterLink: TFrmMasterLink;
  42.  
  43. implementation
  44.  
  45. uses Browse;
  46.  
  47. {$R *.DFM}
  48.  
  49. procedure TFrmMasterLink.FormCreate(Sender: TObject);
  50. var
  51.   I : Integer;
  52. begin
  53.   try
  54.     for I := 0 to Application.ComponentCount - 1 do
  55.       if (Application.Components[I] is TFrmBrowser) then begin
  56.         ComboBox2.Items.AddObject(Application.Components[I].FindComponent('DataSource1').Name,Application.Components[I].FindComponent('DataSource1'));
  57.         ComboBox4.Items.AddObject(Application.Components[I].FindComponent('DataSource1').Name,Application.Components[I].FindComponent('DataSource1'));
  58.       end;
  59.   except
  60.     on E: Exception do
  61.       ShowMessage(E.Message);
  62.   end;
  63. end;
  64.  
  65. procedure TFrmMasterLink.ComboBox2Change(Sender: TObject);
  66. var
  67.   I : Integer;
  68. begin
  69.   TTable(TDataSource(ComboBox2.Items.Objects[ComboBox2.ItemIndex]).DataSet).IndexDefs.Update;
  70.   ComboBox1.Items.Clear;
  71.   for I := 0 to TTable(TDataSource(ComboBox2.Items.Objects[ComboBox2.ItemIndex]).DataSet).IndexDefs.Count - 1 do
  72.     ComboBox1.Items.Add(TTable(TDataSource(ComboBox2.Items.Objects[ComboBox2.ItemIndex]).DataSet).IndexDefs.Items[I].Name);
  73. end;
  74.  
  75. procedure TFrmMasterLink.ComboBox4Change(Sender: TObject);
  76. var
  77.   I : Integer;
  78. begin
  79.   TTable(TDataSource(ComboBox4.Items.Objects[ComboBox4.ItemIndex]).DataSet).IndexDefs.Update;
  80.   ComboBox3.Items.Clear;
  81.   for I := 0 to TTable(TDataSource(ComboBox4.Items.Objects[ComboBox4.ItemIndex]).DataSet).IndexDefs.Count - 1 do
  82.     ComboBox3.Items.Add(TTable(TDataSource(ComboBox4.Items.Objects[ComboBox4.ItemIndex]).DataSet).IndexDefs.Items[I].Name);
  83. end;
  84.  
  85. end.
  86.