Board index » delphi » Component within a component problem

Component within a component problem

The Following is a code snippet from a problem that I am having. I want
to create a listbox within my component. The code executes fine, but the
listbox is not visible. Could somebody please help me. Thanks in
advance.

Ste...@CriticalMass.com

type
  TStringCalendar = class(TCalendar) {TcustomGrid}
  private
    CellList:Celldata;
    DayBox: TListbox;
   .
   .
   .
   .
constructor TStringCalendar.Create(AOwner: TComponent);
VAR

BEGIN
  Inherited Create (AOwner);
  Daybox:=TListbox.Create(AOwner);
  Daybox.Visible:=True;
  Daybox.Left:=0;
  Daybox.Top:=0;
  Daybox.Bringtofront;

 

Re:Component within a component problem


Quote
Steve Cody (Ste...@CriticalMass.Com) wrote:

: The Following is a code snippet from a problem that I am having. I want
: to create a listbox within my component. The code executes fine, but the
: listbox is not visible. Could somebody please help me. Thanks in
: advance.

: Ste...@CriticalMass.com

: type
:   TStringCalendar = class(TCalendar) {TcustomGrid}
:   private
:     CellList:Celldata;
:     DayBox: TListbox;
:    .
:    .
:    .
:    .
: constructor TStringCalendar.Create(AOwner: TComponent);
: VAR

: BEGIN
:   Inherited Create (AOwner);
:   Daybox:=TListbox.Create(AOwner);
:   Daybox.Visible:=True;
:   Daybox.Left:=0;
:   Daybox.Top:=0;
:   Daybox.Bringtofront;

Steve,

For any visual component created at runtime, you must set the parent
property, otherwise the component will not be visible. In your case adding
the line "Daybox.parent := AOwner;" should do the trick.

Good Luck,

-Ray
--
Ray Hildreth  
Greater Columbus Free-Net
rh...@freenet.columbus.oh.us

Other Threads