delphi - Adding a component inside a scrollbox -


I have a custom component, I currently have to put the TScrollbox on the form, then add / Drag the custom component into the scroll box.
How do I go about changing the component, so it automatically puts it inside a scroll box, when it is placed on a form?

A custom component is a TGraphicControl .

If you have a custom component and you always want to be present inside the scrollbalk, the best solution Either there is an example using a TLabel to update or expand that component for your own scrollbox, but you can replace it with your custom component.

  entity MyScrollBox; The interface uses System.SysUtils, System.Classes, Vcl.Controls, Vcl.Forms, Vcl.StdCtrls; Type TMyScrollComponent = Class (TScrollBox) Private FLabel: TLabel; Process SetLabelText (Attack: string); GetLabelText: string; Build Protected Maker (AOwner: TComponent); Override; Published property LabelText: write SetLabelText to write GetLabelText to the string; End; Process register; Register of implementation process; Start Register Components ('Sample', [TMyScrollComponent]); End; Manufacturer TMyScrollComponent.Create (AOwner: TComponent); Heritage begins; Flabell: = Telebell. Create (self); FLabel.Parent: = Self; FLabel.Caption: = 'Hello from scrollbox!'; End; Process TMyScrollComponent.SetLabelText (ATEX: string); Begin FLabel.Caption: = AText; End; The function TMyScrollComponent.GetLabelText: string; Start the result: = Fable. Caption; End; End.   

This represents a custom component that is derived from TScrollBox , it has a TLabel and captions property displays through a custom publish property, after this method of TLabel you can also highlight other properties of your custom control that you want, etc.

Alternatively, if you want to preserve the ability to make layout changes within the scrollbox on design time, the second solution will be to create a custom TFrame . Just and, after a build, in this tool palette the standard - & gt; Becomes available under. Frame .

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -