Atozed Forums

Full Version: Dynamic creation TIWRegion
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to create my own analogue ListBox with custom Items. Try use TIWRegion for it:
Code:
//TBetslipItem = class( TIWRegion );

with TBetslipItem.Create( Self ) do
begin
 Parent := rgnBetslip;// rgnBetslip - primary TIWRegion
 Top    := ( rgnBetslip.IWComponentsCount - 1 ) * 120;
 Left   := 0;
 Width  := 120;
 Height := 120;
 Color  := $00303030;
 RenderInvisibleControls := True;
end;
 
  
 When I create (On Button Click) a component the first time, everything works, But if  create more components, i can see only the last one created:

[attachment=37]
[attachment=38]
[attachment=39]

Number in title shows current rgnBetslip.IWComponentsCount;

What could be the problem ?

P.S. If instead of TIWRegion using TIWRectangle then such a problem does not arise, but I can not place any components on TIWRectangle.

The problem is solved. I did not specify the name of the component, for example:
Name := 'BetslipItem' + IntToStr( rgnBetslip.IWComponentsCount );
(07-31-2018, 02:14 PM)Rassamaha78 Wrote: [ -> ]I want to create my own analogue ListBox with custom Items. Try use TIWRegion for it:
Code:
//TBetslipItem = class( TIWRegion );

with TBetslipItem.Create( Self ) do
begin
 Parent := rgnBetslip;// rgnBetslip - primary TIWRegion
 Top    := ( rgnBetslip.IWComponentsCount - 1 ) * 120;
 Left   := 0;
 Width  := 120;
 Height := 120;
 Color  := $00303030;
 RenderInvisibleControls := True;
end;
 
  
 When I create (On Button Click) a component the first time, everything works, But if  create more components, i can see only the last one created:





Number in title shows current rgnBetslip.IWComponentsCount;

What could be the problem ?

P.S. If instead of TIWRegion using TIWRectangle then such a problem does not arise, but I can not place any components on TIWRectangle.

The problem is solved. I did not specify the name of the component, for example:
Name := 'BetslipItem' + IntToStr( rgnBetslip.IWComponentsCount );

Yes, component name is  mandatory... Thanks for the feedback.
remember that also, if/when you will create Frames too