Einzelnen Beitrag anzeigen

Nuclear-Ping
(Gast)

n/a Beiträge
 
#1

TPanel-Nachfahr Probleme: ComboBox.Items.Add in constructor

  Alt 18. Aug 2004, 13:37
Hallo,

ich will mir einen Nachfahren von TPanel ableiten, der u.A. zwei ComboBoxen in sich trägt.

Die Deklaration schaut so aus:
Delphi-Quellcode:
type
  TVisualGlobalScalingCalculator = class(TPanel)
    constructor Create (AOwner: TComponent); override;
    ...
  private
    { Private-Deklarationen }
    ...
 
    FPhaseShiftCombo,
    FYSelectCombo: TComboBox;
 
  ...
  end;
Der constructor so:

Delphi-Quellcode:
 { ************************************************************ }
constructor TVisualGlobalScalingCalculator.Create (AOwner: TComponent);
{ ************************************************************ }
begin
  inherited Create (AOwner);
 
  // -------------------------------------------------
 
  FGageSelectPanel := TPanel.Create (Self);
  FFormularPanel := TPanel.Create (Self);
 
  // -------------------------------------------------
 
  ...
  FYSelectCombo := TComboBox.Create (FGageSelectPanel);
 
  // -------------------------------------------------
 
  ...
 
  // -------------------------------------------------
 
  FPhaseShiftCombo := TComboBox.Create (FFormularPanel);
 
  // -------------------------------------------------
 
  ...
 
  // -------------------------------------------------
 
  with FYSelectCombo do
    begin
      Parent := FGageSelectPanel;
      Name := 'FYSelectCombo';
      Style := csDropDownList;
 
      OnChange := GageChangeEvent;
      OnSelect := GageChangeEvent;
 
// Items.Add ('test'); <<-- Fehler
    end;
 
  // -------------------------------------------------
 
  ...
 
  // -------------------------------------------------
 
  with FPhaseShiftCombo do
    begin
      Parent := FFormularPanel;
      Name := 'FPhaseShiftCombo';
      Style := csDropDownList;
 
// Items.Add (' 0.0'); <<-- Fehler
// Items.Add (' 1.5');
// Items.Add ('-1.5');
    end;
 
  // -------------------------------------------------
 
  ...
 
end;
Im Konstruktor sollen also Standardwerte in die ComboBoxen aufgenommen werden. Jedoch verursacht er bei den (nun) auskommentierten "Items.Add"-Anweisungen eine Fehlermeldung: "Element '' hat kein übergeordnetes Fenster.", wenn ich die Komponente auf die Form ziehe.

Allerdings sind alle Parent-Zuweisungen korrekt und später lassen sich auch ohne Probleme Items zu den ComboBoxen hinzufügen.

Wo liegt hier der Fallstrick und wie kann ich im Konstruktor den ComboBoxen Standardwerte geben?

Vielen Dank im Vorraus,
Mario
  Mit Zitat antworten Zitat