Einzelnen Beitrag anzeigen

raena

Registriert seit: 30. Dez 2007
124 Beiträge
 
#15

Re: Variablenübergabe - ich verzweifle

  Alt 19. Apr 2008, 17:19
Hi Muh Kuh,

jepp es klappt vielen Merci.
Manche einfach erscheinende Dinge kosten oft viel Schweiss.
Ich habe die Sache jetzt mal für den "Transfer" von ListBoxen umgebogen.

Vielen Dank.

Delphi-Quellcode:
unit Main;

interface

uses
  Sub, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm3 = class(TForm)
    Button1: TButton;
    ListBoxMain: TListBox;

    procedure Button1Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  FormMain: TForm3;

implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
var
  i: integer;
begin
  with TForm5.Create(Application) do
  begin
    try
      ListBoxMain.Items[0]:='erster eintrag';
      ListBoxMain.Items[1]:='zweiter eintrag';
      ListBoxMain.Items[2]:='noch ein eintrag';
      listboxtrans:=listboxmain;
      ShowModal;
    finally
      Free;
    end;
  end;
end;
end.
Delphi-Quellcode:
unit Sub;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm5 = class(TForm)
    ListBox1: TListBox;
  private
    function GetListBox(): Tlistbox;
    procedure SetListBox(const Value: TListBox);
  public
    property ListBoxTrans: TListBox read GetListBox write SetListBox;
  end;
     var FormSub: TForm5;
implementation
{$R *.dfm}


function TForm5.GetListBox: TListBox;
begin
GetListBox:= listbox1;
end;

procedure TForm5.SetListBox(const Value: TListBox);
var i:integer;
begin
 for i := 0 to value.Count - 1 do ListBox1.Items[i]:=value.Items[i];
end;

end.
  Mit Zitat antworten Zitat