was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

50 Visitors Online


 
...Daten von einer anderen MDI-Child Form lesen?
Autor: Carlos Borrero
[ Tip ausdrucken ]  

Tip Bewertung (6):  
     


type
  
TMDIChildForm = class(TForm)
    Edit1: TEdit;
  private
    
{ Private declarations }
    
procedure ReadDataFromOtherMDIChildForm;
  end;

var
  
MDIChildForm: TMDIChildForm;

implementation

{$R *.DFM}

uses
  
MainForm;
  // Property FormStyle of this form is fsMDIForm

procedure TMDIChildForm.ReadDataFromOtherMDIChildForm;
var
  
i: Integer;
  DataFromOtherForm: string;
begin
  
// Suppose you have created three different MDIChild forms of the same type,
  // each with the following caption: "aaa", "bbb", "ccc".
  // You are currently on form with caption "aaa" and want to read data
  // contained on form with caption "ccc".
  // You can find here the code, you have to use the "as" clause and
  // properties MDIChildCount and MDIChildren:

  // First you have to find where the form "ccc" is in memory;
  
for i := 0 to MDIForm.MDIChildCount - 1 do
  begin
    if 
(Pos('ccc', MDIForm.MDIChildren[i].Caption)  0) then
      
Break;
  end;
  // Check to see if the form is the last on MDIChildren array and
  // correct I variable
  
if (i = MDIChildCount) then Dec(i);
  // I variable contains the index of the form with caption 'ccc'

  
if (Pos('ccc', MDIForm.MDIChildren[i].Caption)  0) then
  begin
    
// If the form with caption 'ccc' exists then you access data and show it
    // The following line of code is very interesting, look at the "as" clause,
    // if you have different types of MDIChild forms, you simply change
    // the type of form after the "as" clause
    // The data you want is contained on Edit1.Text
    
with (MDIForm.MDIChildren[I] as TMDIChildForm).Edit1 do
      
DataFromOtherForm := Text;
    ShowMessage(DataFromOtherForm);
  end;
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners