AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Objektbehandlung

Ein Thema von Ginko · begonnen am 30. Mär 2010 · letzter Beitrag vom 30. Mär 2010
 
Ginko

Registriert seit: 30. Aug 2008
208 Beiträge
 
FreePascal / Lazarus
 
#1

Objektbehandlung

  Alt 30. Mär 2010, 12:32
Hallo, ich hätte mal eine allgemeine Frage zur Objektbehandlung.
Also wenn ich zum Beispiel ein Objekt erzeugen will, welches aus einer Listbox und einem Edit-Feld besteht, welches z.B. dazu dient die einzelnen Zeilen in der Listbox anzuwählen, wie geht man da am besten vor ?
Ich habe mal zwei Beispile gemacht, wobei das 2te ja sehr viel umständlicher ist. Aber kann man das erste ohne bedenken holen, da ja ein zweites Objekt vom ersten erszeugt wird?

Delphi-Quellcode:
1.
type
  TMyList = class(TListBox)
  private
    fAuswahl: TEdit;
  public
    constructor Create(AOwner: TComponent); override;
  end;

implementation

constructor TMyList.Create;
begin
  inherited;
  Parent := AOwner as TWinControl;

  fAuswahl := TEdit.Create(AOwner);
  with fAuswahl do
  begin
    Parent := AOwner as TWinControl;
    Left := 130;
  end;
end;
Delphi-Quellcode:
2.
type
  TMyEdit = class(TEdit)
  public
    constructor Create(AOwner: TComponent); override;
  end;

  TMyList = class(TListBox)
  private
    fAuswahl: TMyEdit;
  public
    constructor Create(AOwner: TComponent; InAuswahl: TMyEdit); reintroduce;
  end;

implementation

constructor TMyEdit.Create;
begin
  inherited;
  Parent := AOwner as TWinControl;
  Left := 130;
end;

constructor TMyList.Create;
begin
  inherited Create(AOwner);
  Parent := AOwner as TWinControl;
  fAuswahl := InAuswahl;
end;
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:56 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz