Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>(I will assume that each form resides in its own unit.) First, you have to make sure that <code>idList</code> is accessible to other units. For example,</p> <pre><code>unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) private { Private declarations } idList: integer; public { Public declarations } end; </code></pre> <p>will not do, but</p> <pre><code>unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) private { Private declarations } public { Public declarations } idList: integer; end; </code></pre> <p>is OK. In such case, all you need to do in <code>Unit2</code> is to add <code>Unit1</code> to its 'uses list' (press Alt+F11, or use File/'Use Unit...', while in <code>Unit2</code> or while editing <code>Form2</code>). Then you can use <code>Form1.idList</code> to access the variable anywhere inside <code>Unit2</code>. (<code>Form1</code> is the global instance variable of <code>TForm1</code> in <code>Unit1</code>).</p> <p>For example,</p> <pre><code>unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm2 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form2: TForm2; implementation uses Unit1; // &lt;-- Add manually, or press Alt+F11 (or use File/'Use Unit...') {$R *.dfm} procedure TForm2.Button1Click(Sender: TObject); begin ShowMessage(IntToStr(Form1.idList)); end; end. </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload